Skip to content

Failed assertion in _PyEval_EvalFrameDefault: self_o != NULL #132011

Closed
@devdanzin

Description

@devdanzin

Crash report

What happened?

It's possible to make the interpreter exit with a failed assertion by running the following code:

import difflib

obj = difflib.HtmlDiff(None, None, None, None,)

try:
    for x in range(3):
        obj._split_line([], None, None)
except:
    pass

obj._split_line(list, None, None)

Backtrace:

python: Python/generated_cases.c.h:3345: _PyEval_EvalFrameDefault: Assertion `self_o != 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=0x555555a43bc6 "self_o != NULL", file=0x555555a43993 "Python/generated_cases.c.h", line=3345,
    function=<optimized out>) at ./assert/assert.c:94
#6  0x00007ffff7cd7e96 in __GI___assert_fail (assertion=assertion@entry=0x555555a43bc6 "self_o != NULL",
    file=file@entry=0x555555a43993 "Python/generated_cases.c.h", line=line@entry=3345,
    function=function@entry=0x555555a44980 <__PRETTY_FUNCTION__.81> "_PyEval_EvalFrameDefault") at ./assert/assert.c:103
#7  0x0000555555837189 in _PyEval_EvalFrameDefault (tstate=tstate@entry=0x555555c6b558 <_PyRuntime+330424>, frame=0x7ffff7fb00a0,
    frame@entry=0x7ffff7fb0020, throwflag=throwflag@entry=0) at Python/generated_cases.c.h:3345
#8  0x000055555585db58 in _PyEval_EvalFrame (throwflag=0, frame=0x7ffff7fb0020, tstate=0x555555c6b558 <_PyRuntime+330424>)
    at ./Include/internal/pycore_ceval.h:119
#9  _PyEval_Vector (tstate=tstate@entry=0x555555c6b558 <_PyRuntime+330424>, func=func@entry=0x7ffff7a8db50,
    locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/fusil/runs/python-12/difflib-abort-assertion/source2.py') at remote 0x7ffff7a95b90>, '__spec__': None, '__builtins__': <module at remote 0x7ffff7befef0>, '__file__': '/home/fusil/runs/python-12/difflib-abort-assertion/source2.py', '__cached__': None, 'difflib': <module at remote 0x7ffff7acc110>, 'obj': <HtmlDiff(_charjunk=None, _linejunk=None, _tabsize=None, _wrapcolumn=None) at remote 0x7ffff7a7be40>, 'x': 2}, args=args@entry=0x0, argcount=argcount@entry=0, kwnames=kwnames@entry=0x0) at Python/ceval.c:1908
#10 0x000055555585dc57 in PyEval_EvalCode (co=co@entry=<code at remote 0x7ffff7bce400>,
    globals=globals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/fusil/runs/python-12/difflib-abort-assertion/source2.py') at remote 0x7ffff7a95b90>, '__spec__': None, '__builtins__': <module at remote 0x7ffff7befef0>, '__file__': '/home/fusil/runs/python-12/difflib-abort-assertion/source2.py', '__cached__': None, 'difflib': <module at remote 0x7ffff7acc110>, 'obj': <HtmlDiff(_charjunk=None, _linejunk=None, _tabsize=None, _wrapcolumn=None) at remote 0x7ffff7a7be40>, 'x': 2},
    locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/fusil/runs/python-12/difflib-abort-assertion/source2.py') at remote 0x7ffff7a95b90>, '__spec__': None, '__builtins__': <module at remote 0x7ffff7befef0>, '__file__': '/home/fusil/runs/python-12/difflib-abort-assertion/source2.py', '__cached__': None, 'difflib': <module at remote 0x7ffff7acc110>, 'obj': <HtmlDiff(_charjunk=None, _linejunk=None, _tabsize=None, _wrapcolumn=None) at remote 0x7ffff7a7be40>, 'x': 2}) at Python/ceval.c:836
#11 0x00005555558eb82e in run_eval_code_obj (tstate=tstate@entry=0x555555c6b558 <_PyRuntime+330424>, co=co@entry=0x7ffff7bce400,
    globals=globals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/fusil/runs/python-12/difflib-abort-assertion/source2.py') at remote 0x7ffff7a95b90>, '__spec__': None, '__builtins__': <module at remote 0x7ffff7befef0>, '__file__': '/home/fusil/runs/python-12/difflib-abort-assertion/source2.py', '__cached__': None, 'difflib': <module at remote 0x7ffff7acc110>, 'obj': <HtmlDiff(_charjunk=None, _linejunk=None, _tabsize=None, _wrapcolumn=None) at remote 0x7ffff7a7be40>, 'x': 2},
    locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/fusil/runs/python-12/difflib-abort-assertion/source2.py') at remote 0x7ffff7a95b90>, '__spec__': None, '__builtins__': <module at remote 0x7ffff7befef0>, '__file__': '/home/fusil/runs/python-12/difflib-abort-assertion/source2.py', '__cached__': None, 'difflib': <module at remote 0x7ffff7acc110>, 'obj': <HtmlDiff(_charjunk=None, _linejunk=None, _tabsize=None, _wrapcolumn=None) at remote 0x7ffff7a7be40>, 'x': 2}) at Python/pythonrun.c:1365

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

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

Python 3.14.0a6+ (heads/main:3a8cefba0b6, Apr 1 2025, 21:31:55) [GCC 11.4.0]

Linked PRs

Metadata

Metadata

Assignees

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)type-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