Skip to content

Segfault in gc while finalizing #135115

Open
@dimaqq

Description

@dimaqq

Crash report

What happened?

I believe I have been able to hit this twice by now, though the incidence is low: about 10 hours of running unit tests back-to-back yielded me one crash where a core dump was captured.

Setup: mostly pure python (with wrapt, cyaml and pydantic), with threads (opentelemetry-sdk helper thread) and some form of multi- or sub-processing (pytest-xdist).

Tracback:

#0  gc_get_refs (g=0x99dd7d052835e0c0) at Python/gc.c:71
#1  move_unreachable (young=0x5e558d4e2890 <_PyRuntime+111872>, unreachable=0x7ffc77bd0718) at Python/gc.c:562
#2  deduce_unreachable (base=base@entry=0x5e558d4e2890 <_PyRuntime+111872>, unreachable=unreachable@entry=0x7ffc77bd0718) at Python/gc.c:1125
#3  0x00005e558c21f0ef in gc_collect_main (tstate=tstate@entry=0x5e558d5103b0 <_PyRuntime+299040>, generation=generation@entry=2, reason=reason@entry=_Py_GC_REASON_SHUTDOWN)
    at Python/gc.c:1360
#4  0x00005e558c21ff74 in _PyGC_CollectNoFail (tstate=0x7c514fdce4e0, tstate@entry=0x5e558d5103b0 <_PyRuntime+299040>) at Python/gc.c:1657
#5  0x00005e558c257dee in finalize_modules (tstate=tstate@entry=0x5e558d5103b0 <_PyRuntime+299040>) at Python/pylifecycle.c:1795
#6  0x00005e558c256829 in _Py_Finalize (runtime=0x5e558d4c7390 <_PyRuntime>) at Python/pylifecycle.c:2132
#7  0x00005e558c256687 in Py_FinalizeEx () at Python/pylifecycle.c:2259
#8  0x00005e558c2a7e74 in Py_RunMain () at Modules/main.c:777
#9  0x00005e558c2a86f1 in pymain_main (args=args@entry=0x7ffc77bd0b40) at Modules/main.c:805
#10 0x00005e558c2a874c in Py_BytesMain (argc=<optimized out>, argv=0x5e558c2217b0 <visit_reachable>) at Modules/main.c:829
#11 0x00007c515762a1ca in __libc_start_call_main (main=main@entry=0x5e558bfd3aa0 <main>, argc=argc@entry=4, argv=argv@entry=0x7ffc77bd0c88)
    at ../sysdeps/nptl/libc_start_call_main.h:58
#12 0x00007c515762a28b in __libc_start_main_impl (main=0x5e558bfd3aa0 <main>, argc=4, argv=0x7ffc77bd0c88, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>,
    stack_end=0x7ffc77bd0c78) at ../csu/libc-start.c:360
#13 0x00005e558bfd39d2 in _start ()

gdb session:
https://gist.github.com/dimaqq/cd87dfdad4e0cc1d5832fa226e516ff0

Admittedly I'm a little rusty with gdb and a bit out of my depth when it comes to GC.

CPython versions tested on:

3.13

Operating systems tested on:

Linux

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

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    pendingThe issue will be closed if no feedback is providedtype-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