New GitHub issue #94736 from kumaraditya303:<br>

<hr>

<pre>
<!--
  Use this template for hard crashes of the interpreter, segmentation faults, failed C-level assertions, and similar.
  Do not submit this form if you encounter an exception being unexpectedly raised from a Python function.
  Most of the time, these should be filed as bugs, rather than crashes.

  The CPython interpreter is itself written in a different programming language, C.
  For CPython, a "crash" is when Python itself fails, leading to a traceback in the C stack.
-->

**Crash report**

GC crash in subtype_dealloc when inherting from _multiprocessing.SemLock.

Reproducer:
```py
from _multiprocessing import SemLock
import os
os.system("rm -rf /dev/shm/*")

class S(SemLock):
    pass


s = S(1, 1, 2, 'foo', 1)
```

**Error messages**

```console
@kumaraditya303 ➜ /workspaces/cpython (main ✗) $ ./python main.py 
Segmentation fault (core dumped)
```
GDB backtrace:
```console
#0  _PyObject_GC_UNTRACK (op=<S() at remote 0x7ffff778d480>, lineno=2242, 
    filename=0x5555559ae5dc "Modules/gcmodule.c") at ./Include/internal/pycore_object.h:174
#1  PyObject_GC_UnTrack (op_raw=0x7ffff778d480) at Modules/gcmodule.c:2242
#2  0x0000555555760e71 in subtype_dealloc (self=<S() at remote 0x7ffff778d480>)
    at Objects/typeobject.c:1368
#3  0x0000555555742e85 in _Py_Dealloc (op=<optimized out>) at Objects/object.c:2382
#4  0x0000555555726b1b in Py_DECREF (op=<optimized out>, lineno=609, 
    filename=0x55555591d5dd "./Include/object.h") at ./Include/object.h:533
#5  Py_XDECREF (op=<optimized out>) at ./Include/object.h:609
#6  free_keys_object (keys=keys@entry=0x7ffff777cf70) at Objects/dictobject.c:664
#7  0x0000555555727258 in dictkeys_decref (dk=0x7ffff777cf70) at Objects/dictobject.c:324
#8  dict_dealloc (mp=0x7ffff772d490) at Objects/dictobject.c:2378
#9  0x0000555555742e85 in _Py_Dealloc (op=<optimized out>) at Objects/object.c:2382
#10 0x000055555573f7e9 in Py_DECREF (op=<optimized out>, lineno=609, 
    filename=0x55555591d5dd "./Include/object.h") at ./Include/object.h:533
#11 Py_XDECREF (op=<optimized out>) at ./Include/object.h:609
#12 module_dealloc (m=0x7ffff772da30) at Objects/moduleobject.c:699
#13 0x0000555555742e85 in _Py_Dealloc (op=<optimized out>) at Objects/object.c:2382
#14 0x000055555572bca7 in Py_DECREF (op=<optimized out>, lineno=609, 
```


**Your environment**

<!-- Include as many relevant details as possible about the environment you experienced the bug in -->

- CPython versions tested on: Python 3.12.0a0 da717519ec, Python 3.11.0b3+ f3212b1ec7 on linux
- Operating system and architecture: Linux 5.4.0-1074-azure  x86_64 

<!--
You can freely edit this text. Remove any lines you believe are unnecessary.
-->

cc @pablogsal 
</pre>

<hr>

<a href="https://github.com/python/cpython/issues/94736">View on GitHub</a>
<p>Labels: release-blocker, 3.11, 3.10, type-crash, 3.12</p>
<p>Assignee: </p>