Skip to content

Assertion failure in _PyEval_EvalFrameDefault with generators and LINE/INSTRUCTION event monitoring #118414

Closed

Description

@chgnrdv

Crash report

What happened?

Bisected to 3e06c7f, where given assertion was added.

Repro:

from sys import monitoring as mon

mon.use_tool_id(mon.DEBUGGER_ID, "test")
mon.set_events(mon.DEBUGGER_ID, mon.events.LINE)

def a():
    yield

def b():
    yield from a()

next(b())

Output:

python: Python/generated_cases.c.h:6035: _PyEval_EvalFrameDefault: Assertion `_PyOpcode_Deopt[frame->instr_ptr->op.code] == SEND || _PyOpcode_Deopt[frame->instr_ptr->op.code] == FOR_ITER || _PyOpcode_Deopt[frame->instr_ptr->op.code] == INTERPRETER_EXIT || _PyOpcode_Deopt[frame->instr_ptr->op.code] == ENTER_EXECUTOR' failed.
Fatal Python error: Aborted

Current thread 0x00007f7a88d3f280 (most recent call first):
  File "/home/radislav/projects/cpython/repro.py", line 12 in b
  File "/home/radislav/projects/cpython/repro.py", line 14 in <module>
Aborted (core dumped)

Backtrace:

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff7c85537 in __GI_abort () at abort.c:79
#2  0x00007ffff7c8540f in __assert_fail_base (fmt=0x7ffff7dfc688 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=0x555555a0fe30 "_PyOpcode_Deopt[frame->instr_ptr->op.code] == SEND || _PyOpcode_Deopt[frame->instr_ptr->op.code] == FOR_ITER || _PyOpcode_Deopt[frame->instr_ptr->op.code] == INTERPRETER_EXIT || _PyOpcode_Deopt[frame-"..., file=0x555555a0db6f "Python/generated_cases.c.h", line=6035, function=<optimized out>) at assert.c:92
#3  0x00007ffff7c94662 in __GI___assert_fail (
    assertion=assertion@entry=0x555555a0fe30 "_PyOpcode_Deopt[frame->instr_ptr->op.code] == SEND || _PyOpcode_Deopt[frame->instr_ptr->op.code] == FOR_ITER || _PyOpcode_Deopt[frame->instr_ptr->op.code] == INTERPRETER_EXIT || _PyOpcode_Deopt[frame-"..., file=file@entry=0x555555a0db6f "Python/generated_cases.c.h", line=line@entry=6035, 
    function=function@entry=0x555555a10fa0 <__PRETTY_FUNCTION__.69> "_PyEval_EvalFrameDefault") at assert.c:101
#4  0x00005555558296b5 in _PyEval_EvalFrameDefault (tstate=tstate@entry=0x555555c27138 <_PyRuntime+308728>, frame=frame@entry=0x200003827c8, 
    throwflag=throwflag@entry=0) at Python/generated_cases.c.h:6035
#5  0x00005555556aaab4 in _PyEval_EvalFrame (throwflag=0, frame=0x200003827c8, tstate=0x555555c27138 <_PyRuntime+308728>) at ./Include/internal/pycore_ceval.h:118
#6  gen_send_ex2 (gen=0x20000382770, arg=arg@entry=0x0, presult=presult@entry=0x7fffffffda58, exc=exc@entry=0, closing=closing@entry=0) at Objects/genobject.c:228
#7  0x00005555556ab174 in gen_iternext (gen=<optimized out>) at Objects/genobject.c:586
#8  0x0000555555801a9d in builtin_next (self=<optimized out>, args=0x7ffff7fc1078, nargs=1) at Python/bltinmodule.c:1534
#9  0x00005555556f934c in cfunction_vectorcall_FASTCALL (func=0x200003a02b0, args=0x7ffff7fc1078, nargsf=<optimized out>, kwnames=<optimized out>)
    at Objects/methodobject.c:425
#10 0x0000555555682724 in _PyObject_VectorcallTstate (tstate=0x555555c27138 <_PyRuntime+308728>, callable=0x200003a02b0, args=0x7ffff7fc1078, 
    nargsf=9223372036854775809, kwnames=0x0) at ./Include/internal/pycore_call.h:168
#11 0x000055555568283f in PyObject_Vectorcall (callable=callable@entry=0x200003a02b0, args=args@entry=0x7ffff7fc1078, nargsf=<optimized out>, kwnames=kwnames@entry=0x0)
    at Objects/call.c:327
#12 0x000055555581436b in _PyEval_EvalFrameDefault (tstate=tstate@entry=0x555555c27138 <_PyRuntime+308728>, frame=0x7ffff7fc1020, throwflag=throwflag@entry=0)
    at Python/generated_cases.c.h:813
#13 0x00005555558322e6 in _PyEval_EvalFrame (throwflag=0, frame=<optimized out>, tstate=0x555555c27138 <_PyRuntime+308728>) at ./Include/internal/pycore_ceval.h:118
#14 _PyEval_Vector (tstate=tstate@entry=0x555555c27138 <_PyRuntime+308728>, func=func@entry=0x20000ad0610, locals=locals@entry=0x20000746d90, args=args@entry=0x0, 
    argcount=argcount@entry=0, kwnames=kwnames@entry=0x0) at Python/ceval.c:1811
#15 0x0000555555832394 in PyEval_EvalCode (co=co@entry=0x200003e3010, globals=globals@entry=0x20000746d90, locals=locals@entry=0x20000746d90) at Python/ceval.c:602
#16 0x00005555558bf007 in run_eval_code_obj (tstate=tstate@entry=0x555555c27138 <_PyRuntime+308728>, co=co@entry=0x200003e3010, globals=globals@entry=0x20000746d90, 
    locals=locals@entry=0x20000746d90) at Python/pythonrun.c:1291
#17 0x00005555558c11d9 in run_mod (mod=mod@entry=0x20000b61a50, filename=filename@entry=0x20000aa1a50, globals=globals@entry=0x20000746d90, 
    locals=locals@entry=0x20000746d90, flags=flags@entry=0x7fffffffdf98, arena=arena@entry=0x20000031bd0, interactive_src=<optimized out>, 
    generate_new_source=<optimized out>) at Python/pythonrun.c:1376
#18 0x00005555558c155c in pyrun_file (fp=fp@entry=0x555555cbbb30, filename=filename@entry=0x20000aa1a50, start=start@entry=257, globals=globals@entry=0x20000746d90, 
    locals=locals@entry=0x20000746d90, closeit=closeit@entry=1, flags=0x7fffffffdf98) at Python/pythonrun.c:1212
#19 0x00005555558c29b7 in _PyRun_SimpleFileObject (fp=fp@entry=0x555555cbbb30, filename=filename@entry=0x20000aa1a50, closeit=closeit@entry=1, 
    flags=flags@entry=0x7fffffffdf98) at Python/pythonrun.c:461
#20 0x00005555558c2d3c in _PyRun_AnyFileObject (fp=fp@entry=0x555555cbbb30, filename=filename@entry=0x20000aa1a50, closeit=closeit@entry=1, 
--Type <RET> for more, q to quit, c to continue without paging--
    flags=flags@entry=0x7fffffffdf98) at Python/pythonrun.c:77
#21 0x00005555558ebbdf in pymain_run_file_obj (program_name=program_name@entry=0x20000ab0610, filename=filename@entry=0x20000aa1a50, skip_source_first_line=0)
    at Modules/main.c:357
#22 0x00005555558ebeb6 in pymain_run_file (config=config@entry=0x555555bf9430 <_PyRuntime+121072>) at Modules/main.c:376
#23 0x00005555558ed57b in pymain_run_python (exitcode=exitcode@entry=0x7fffffffe11c) at Modules/main.c:628
#24 0x00005555558ed5e9 in Py_RunMain () at Modules/main.c:707
#25 0x00005555558ed63d in pymain_main (args=args@entry=0x7fffffffe160) at Modules/main.c:737
#26 0x00005555558ed6b2 in Py_BytesMain (argc=<optimized out>, argv=<optimized out>) at Modules/main.c:761
#27 0x00005555555d57de in main (argc=<optimized out>, argv=<optimized out>) at ./Programs/python.c:15

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

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

Python 3.13.0a6+ (heads/main:5a90de0d4c, Apr 30 2024, 00:01:27) [GCC 10.2.1 20210110]

Linked PRs

Activity

  1. added
    type-crashA hard crash of the interpreter, possibly with a core dump
    on Apr 30, 2024
  2. mdboom commented on Apr 30, 2024

    @mdboom
    Contributor

    Cc @markshannon as author of 3e06c7f

  3. added a commit that references this issue on May 7, 2024
  4. gaogaotiantian commented on May 7, 2024

    @gaogaotiantian
    Member

    Fixed in #118683

  5. added a commit that references this issue on May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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