Crash report
What happened?
It's possible to segfault or abort the interpreter with the following code:
class WeirdDict(dict): pass ns = {} exec("def __create_fn__():\n return a", WeirdDict({None: None}), ns) ns['__create_fn__']()
Segfault backtrace:
Program received signal SIGSEGV, Segmentation fault. _PyEval_LoadGlobalStackRef (globals=<optimized out>, builtins=<optimized out>, name=0x555555aeace0 <_PyRuntime+80128>, writeto=0x7ffff7fb00f8) at Python/ceval.c:3317 3317 *writeto = PyStackRef_FromPyObjectSteal(res); (gdb) bt #0 _PyEval_LoadGlobalStackRef (globals=<optimized out>, builtins=<optimized out>, name=0x555555aeace0 <_PyRuntime+80128>, writeto=0x7ffff7fb00f8) at Python/ceval.c:3317 #1 0x00005555555e22f2 in _PyEval_EvalFrameDefault (tstate=0x555555b24178 <_PyRuntime+314776>, frame=<optimized out>, throwflag=<optimized out>) at Python/generated_cases.c.h:9073 #2 0x00005555557ab807 in _PyEval_EvalFrame (throwflag=0, frame=0x7ffff7fb0020, tstate=0x555555b24178 <_PyRuntime+314776>) at ./Include/internal/pycore_ceval.h:119 #3 _PyEval_Vector (args=0x0, argcount=0, kwnames=0x0, locals=0x7ffff7a4d240, func=0x7ffff7a50f60, tstate=0x555555b24178 <_PyRuntime+314776>) at Python/ceval.c:1913 #4 PyEval_EvalCode (co=co@entry=0x7ffff7bf5920, globals=globals@entry=0x7ffff7a4d240, locals=locals@entry=0x7ffff7a4d240) at Python/ceval.c:829 #5 0x000055555581f3bc in run_eval_code_obj (locals=0x7ffff7a4d240, globals=0x7ffff7a4d240, co=0x7ffff7bf5920, tstate=0x555555b24178 <_PyRuntime+314776>) at Python/pythonrun.c:1365 #6 run_mod (mod=<optimized out>, filename=filename@entry=0x7ffff7a066b0, globals=globals@entry=0x7ffff7a4d240, locals=locals@entry=0x7ffff7a4d240, flags=flags@entry=0x7fffffffdc18, arena=arena@entry=0x7ffff7b5e210, interactive_src=0x0, generate_new_source=0) at Python/pythonrun.c:1436 #7 0x0000555555821456 in pyrun_file (flags=0x7fffffffdc18, closeit=1, locals=0x7ffff7a4d240, globals=0x7ffff7a4d240, start=257, filename=0x7ffff7a066b0, fp=0x555555b97510) at Python/pythonrun.c:1293
Abort backtrace:
python: ./Include/internal/pycore_stackref.h:447: PyStackRef_FromPyObjectSteal: Assertion `obj != NULL' failed. Program received signal SIGABRT, Aborted. __pthread_kill_implementation (no_tid=0, signo=6, threadid=140737350580032) at ./nptl/pthread_kill.c:44 44 ./nptl/pthread_kill.c: No such file or directory. (gdb) bt #0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=140737350580032) at ./nptl/pthread_kill.c:44 #1 __pthread_kill_internal (signo=6, threadid=140737350580032) at ./nptl/pthread_kill.c:78 #2 __GI___pthread_kill (threadid=140737350580032, signo=signo@entry=6) at ./nptl/pthread_kill.c:89 #3 0x00007ffff7ce0476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 #4 0x00007ffff7cc67f3 in __GI_abort () at ./stdlib/abort.c:79 #5 0x00007ffff7cc671b in __assert_fail_base ( fmt=0x7ffff7e7b130 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x555555a5971d "obj != NULL", file=0x5555559dc630 "./Include/internal/pycore_stackref.h", line=447, function=<optimized out>) at ./assert/assert.c:94 #6 0x00007ffff7cd7e96 in __GI___assert_fail (assertion=assertion@entry=0x555555a5971d "obj != NULL", file=file@entry=0x5555559dc630 "./Include/internal/pycore_stackref.h", line=line@entry=447, function=function@entry=0x555555a42180 <__PRETTY_FUNCTION__.23> "PyStackRef_FromPyObjectSteal") at ./assert/assert.c:103 #7 0x0000555555829da7 in PyStackRef_FromPyObjectSteal (obj=<optimized out>) at ./Include/internal/pycore_stackref.h:447 #8 _PyEval_LoadGlobalStackRef (globals=<optimized out>, builtins=<optimized out>, name='a', writeto=writeto@entry=0x7ffff7fb00f8) at Python/ceval.c:3312 #9 0x000055555584e4ba in _PyEval_EvalFrameDefault ( tstate=tstate@entry=0x555555c69558 <_PyRuntime+330424>, frame=0x7ffff7fb00a8, frame@entry=0x7ffff7fb0020, throwflag=throwflag@entry=0) at Python/generated_cases.c.h:9086 #10 0x000055555585cd69 in _PyEval_EvalFrame (throwflag=0, frame=0x7ffff7fb0020, tstate=0x555555c69558 <_PyRuntime+330424>) at ./Include/internal/pycore_ceval.h:119
Found using fusil by @vstinner.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux, Windows
Output from running 'python -VV' on the command line:
Python 3.14.0a7+ (heads/main:d87e7f35297, Apr 11 2025, 06:20:25) [GCC 11.4.0]