Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GC aborts in debug no-gil build #126312

Closed
Closed
Labels
3.13bugs and security fixes3.14bugs and security fixesextension-modulesC modules in the Modules dirtopic-free-threadingtype-crashA hard crash of the interpreter, possibly with a core dump
@devdanzin

Description

@devdanzin

Crash report

What happened?

In debug no-gil builds withPYTHON_GIL=0, it's possible to trigger the three assertions here with simple code:

_PyObject_ASSERT_WITH_MSG(op, !gc_is_unreachable(op),
"object should not be marked as unreachable yet");
if (_Py_REF_IS_MERGED(op->ob_ref_shared)) {
_PyObject_ASSERT_WITH_MSG(op,op->ob_tid==0,
"merged objects should have ob_tid == 0");
}
elseif (!_Py_IsImmortal(op)) {
_PyObject_ASSERT_WITH_MSG(op,op->ob_tid!=0,

For this code:

importgcgc.freeze()gc.is_finalized(lambda:None)gc.collect()gc.unfreeze()gc.collect()

We get:

Python/gc_free_threading.c:550: validate_refcounts: Assertion "!gc_is_unreachable(op)" failed: object should not be marked as unreachable yetEnable tracemalloc to get the memory block allocation tracebackobject address  : 0x200007373f0object refcount : 1152921504606846977object type     : 0x55adadc26660object type name: dictobject repr     : {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <_frozen_importlib_external.SourceFileLoader object at 0x20000330a20>, '__spec__': None, '__builtins__': <module 'builtins' (built-in)>, '__file__': '/home/fusil/python-61/gc-assertion-abort-2/source.py', '__cached__': None, 'gc': <module 'gc' (built-in)>}Fatal Python error: _PyObject_AssertFailed: _PyObject_AssertFailedPython runtime state: initializedCurrent thread 0x00007f1b47a64740 (most recent call first):  Garbage-collecting  File "/home/fusil/python-61/gc-assertion-abort-2/source.py", line 6 in <module>Aborted

For this code:

fromthreadingimportThreadimportgcgc.freeze()alive= [Thread(target=gc.freeze,args=())]gc.collect()gc.unfreeze()gc.collect()

We get:

Python/gc_free_threading.c:554: validate_refcounts: Assertion "op->ob_tid == 0" failed: merged objects should have ob_tid == 0Enable tracemalloc to get the memory block allocation tracebackobject address  : 0x20000278210object refcount : 1152921504606846994object type     : 0x5616274befc0object type name: typeobject repr     : <class '_thread.lock'>Fatal Python error: _PyObject_AssertFailed: _PyObject_AssertFailedPython runtime state: initializedCurrent thread 0x00007f34ed160740 (most recent call first):  Garbage-collecting  File "/home/fusil/python-104/gc-abort-assertion/source.py", line 8 in <module>Aborted

Lastly, for code I haven't minimized yet (but can, if it helps), we get:

Python/gc_free_threading.c:558: validate_refcounts: Assertion "op->ob_tid != 0" failed: unmerged objects should have ob_tid != 0Enable tracemalloc to get the memory block allocation tracebackobject address  : 0x200007980b0object refcount : 1152921504606846980object type     : 0x5637720b4f40object type name: builtin_function_or_methodobject repr     : <built-in function collect>Fatal Python error: _PyObject_AssertFailed: _PyObject_AssertFailedPython runtime state: initializedCurrent thread 0x00007f63aef4c740 (most recent call first):  Garbage-collecting  File "/home/fusil/python-106/gc-abort-assertion-sigabrt-37/source.py", line 38 in callMethod  File "/home/fusil/python-106/gc-abort-assertion-sigabrt-37/source.py", line 42 in callFunc  File "/home/fusil/python-106/gc-abort-assertion-sigabrt-37/source.py", line 247 in <module>Aborted

Found using fusil by@vstinner.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Output from running 'python -VV' on the command line:

Python 3.14.0a1+ experimental free-threading build (heads/main:d467d9246c, Nov 1 2024, 09:05:56) [GCC 11.4.0]

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixesextension-modulesC modules in the Modules dirtopic-free-threadingtype-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp