Repository navigation
Objects/codeobject.c:814: retreat: Assertion `bounds->ar_start > 0' failed #93249
Copy link
Copy link
Closed
Closed
Copy link
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)release-blockertype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Description
Crash report
Doing a pip install PyQt6 and then running the following script:
from PyQt6.QtCore import QUrl, QTimer, QCoreApplication
app = QCoreApplication([])
timer = QTimer()
timer.setInterval(10)
timer.timeout.connect(lambda: None)
timer.start()
print("Running")
app.exec()and then pressing Ctrl-C (or running signal 2 in gdb) would normally produce:
Running
^CTraceback (most recent call last):
File "/home/florian/tmp/repro.py", line 6, in <lambda>
timer.timeout.connect(lambda: None)
KeyboardInterrupt
(in my case, it seems to crash with a SIGIOT after that, but let's ignore that for now...).
However, with Python 3.11.0b1 configured with --with-pydebug, this happens instead:
Running
^Cpython: Objects/codeobject.c:814: retreat: Assertion `bounds->ar_start > 0' failed.
referring to this line:
Line 814 in 5185956
| assert(bounds->ar_start > 0); |
I was able to bisect this to 944fffe ("GH-88116: Use a compact format to represent end line and column offsets. (GH-91666)", @markshannon).
Error messages
Backtrace:
Details
#0 0x00007ffff7d1636c in ?? () from /usr/lib/libc.so.6
#1 0x00007ffff7cc6838 in raise () from /usr/lib/libc.so.6
#2 0x00007ffff7cb0535 in abort () from /usr/lib/libc.so.6
#3 0x00007ffff7cb045c in ?? () from /usr/lib/libc.so.6
#4 0x00007ffff7cbf366 in __assert_fail () from /usr/lib/libc.so.6
#5 0x00005555556d6b61 in retreat (bounds=bounds@entry=0x7fffffffbab0) at Objects/codeobject.c:799
#6 0x00005555556d9992 in PyCode_Addr2Location (co=<optimized out>, addrq=0, start_line=start_line@entry=0x7fffffffbb40, start_column=start_column@entry=0x7fffffffbb48, end_line=end_line@entry=0x7fffffffbb44, end_column=end_column@entry=0x7fffffffbb4c) at Objects/codeobject.c:902
#7 0x000055555581f36e in tb_displayline (tb=tb@entry=0x7ffff44aa7b0, f=f@entry=<_io.StringIO at remote 0x7ffff762b9d0>, filename='/home/florian/tmp/repro.py', lineno=6, frame=Frame 0x7ffff4498600, for file /home/florian/tmp/repro.py, line 6, in <lambda> (), name=<optimized out>, margin_indent=0, margin=0x5555558cc7df "") at Python/traceback.c:799
#8 0x000055555581f6e9 in tb_printinternal (tb=tb@entry=0x7ffff44aa7b0, f=f@entry=<_io.StringIO at remote 0x7ffff762b9d0>, limit=limit@entry=1000, indent=indent@entry=0, margin=margin@entry=0x5555558cc7df "") at Python/traceback.c:944
#9 0x000055555581f7f9 in _PyTraceBack_Print_Indented (v=v@entry=<traceback at remote 0x7ffff44aa7b0>, indent=0, margin=0x5555558cc7df "", header_margin=header_margin@entry=0x5555558cc7df "", header=0x555555930270 "Traceback (most recent call last):\n", f=f@entry=<_io.StringIO at remote 0x7ffff762b9d0>) at Python/traceback.c:1002
#10 0x000055555580b624 in print_exception_traceback (ctx=ctx@entry=0x7fffffffbd20, value=KeyboardInterrupt()) at Python/pythonrun.c:941
#11 0x000055555580c499 in print_exception (ctx=ctx@entry=0x7fffffffbd20, value=value@entry=KeyboardInterrupt()) at Python/pythonrun.c:1223
#12 0x000055555580c9d7 in print_exception_recursive (ctx=ctx@entry=0x7fffffffbd20, value=value@entry=KeyboardInterrupt()) at Python/pythonrun.c:1508
#13 0x000055555580cee9 in _PyErr_Display (file=file@entry=<_io.StringIO at remote 0x7ffff762b9d0>, exception=exception@entry=<type at remote 0x555555a18160>, value=value@entry=KeyboardInterrupt(), tb=tb@entry=<traceback at remote 0x7ffff44aa7b0>) at Python/pythonrun.c:1551
#14 0x000055555580d054 in PyErr_Display (exception=<type at remote 0x555555a18160>, value=KeyboardInterrupt(), tb=<traceback at remote 0x7ffff44aa7b0>) at Python/pythonrun.c:1583
#15 0x00005555558193ba in sys_excepthook_impl (module=module@entry=<module at remote 0x7ffff78d3770>, exctype=<optimized out>, value=<optimized out>, traceback=<optimized out>) at ./Python/sysmodule.c:738
#16 0x0000555555819422 in sys_excepthook (module=<module at remote 0x7ffff78d3770>, args=0x7fffffffbe70, nargs=<optimized out>) at ./Python/clinic/sysmodule.c.h:73
#17 0x0000555555719d74 in cfunction_vectorcall_FASTCALL (func=<built-in method excepthook of module object at remote 0x7ffff78d3770>, args=0x7fffffffbe70, nargsf=<optimized out>, kwnames=<optimized out>) at Objects/methodobject.c:427
#18 0x00005555556d3231 in _PyObject_VectorcallTstate (tstate=0x555555b378b0 <_PyRuntime+166000>, callable=callable@entry=<built-in method excepthook of module object at remote 0x7ffff78d3770>, args=0x7fffffffbe70, args@entry=0x7fffffffbdf0, nargsf=nargsf@entry=3, kwnames=kwnames@entry=0x0) at ./Include/internal/pycore_call.h:92
#19 0x00005555556d332f in _PyObject_FastCallTstate (nargs=3, args=0x7fffffffbdf0, func=<built-in method excepthook of module object at remote 0x7ffff78d3770>, tstate=<optimized out>) at ./Include/internal/pycore_call.h:114
#20 _PyObject_FastCall (func=func@entry=<built-in method excepthook of module object at remote 0x7ffff78d3770>, args=args@entry=0x7fffffffbe70, nargs=nargs@entry=3) at Objects/call.c:308
#21 0x000055555580d1b5 in _PyErr_PrintEx (tstate=0x555555b378b0 <_PyRuntime+166000>, set_sys_last_vars=set_sys_last_vars@entry=1) at Python/pythonrun.c:825
#22 0x000055555580d453 in PyErr_PrintEx (set_sys_last_vars=set_sys_last_vars@entry=1) at Python/pythonrun.c:875
#23 0x000055555580d466 in PyErr_Print () at Python/pythonrun.c:881
#24 0x00007ffff75170ff in pyqt6_err_print() () from /home/florian/tmp/.venv-retreat/lib/python3.11/site-packages/PyQt6/QtCore.abi3.so
#25 0x00007ffff7520c2d in PyQtSlotProxy::unislot(void**) () from /home/florian/tmp/.venv-retreat/lib/python3.11/site-packages/PyQt6/QtCore.abi3.so
#26 0x00007ffff7522857 in PyQtSlotProxy::qt_metacall(QMetaObject::Call, int, void**) () from /home/florian/tmp/.venv-retreat/lib/python3.11/site-packages/PyQt6/QtCore.abi3.so
#27 0x00007ffff6e1f89d in ?? () from /home/florian/tmp/.venv-retreat/lib/python3.11/site-packages/PyQt6/Qt6/lib/libQt6Core.so.6
#28 0x00007ffff6e2e16a in QTimer::timeout(QTimer::QPrivateSignal) () from /home/florian/tmp/.venv-retreat/lib/python3.11/site-packages/PyQt6/Qt6/lib/libQt6Core.so.6
#29 0x00007ffff74bd103 in sipQTimer::timerEvent(QTimerEvent*) () from /home/florian/tmp/.venv-retreat/lib/python3.11/site-packages/PyQt6/QtCore.abi3.so
#30 0x00007ffff6e1099f in QObject::event(QEvent*) () from /home/florian/tmp/.venv-retreat/lib/python3.11/site-packages/PyQt6/Qt6/lib/libQt6Core.so.6
#31 0x00007ffff749acf3 in sipQTimer::event(QEvent*) () from /home/florian/tmp/.venv-retreat/lib/python3.11/site-packages/PyQt6/QtCore.abi3.so
#32 0x00007ffff74d75be in sipQCoreApplication::notify(QObject*, QEvent*) () from /home/florian/tmp/.venv-retreat/lib/python3.11/site-packages/PyQt6/QtCore.abi3.so
#33 0x00007ffff6dbffba in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /home/florian/tmp/.venv-retreat/lib/python3.11/site-packages/PyQt6/Qt6/lib/libQt6Core.so.6
#34 0x00007ffff6f4d1db in QTimerInfoList::activateTimers() () from /home/florian/tmp/.venv-retreat/lib/python3.11/site-packages/PyQt6/Qt6/lib/libQt6Core.so.6
#35 0x00007ffff7062b3c in ?? () from /home/florian/tmp/.venv-retreat/lib/python3.11/site-packages/PyQt6/Qt6/lib/libQt6Core.so.6
#36 0x00007ffff6937163 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#37 0x00007ffff698d9e9 in ?? () from /usr/lib/libglib-2.0.so.0
#38 0x00007ffff69346c5 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#39 0x00007ffff7062e4a in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /home/florian/tmp/.venv-retreat/lib/python3.11/site-packages/PyQt6/Qt6/lib/libQt6Core.so.6
#40 0x00007ffff6dcc1eb in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /home/florian/tmp/.venv-retreat/lib/python3.11/site-packages/PyQt6/Qt6/lib/libQt6Core.so.6
#41 0x00007ffff6dc7dae in QCoreApplication::exec() () from /home/florian/tmp/.venv-retreat/lib/python3.11/site-packages/PyQt6/Qt6/lib/libQt6Core.so.6
#42 0x00007ffff745187f in meth_QCoreApplication_exec () from /home/florian/tmp/.venv-retreat/lib/python3.11/site-packages/PyQt6/QtCore.abi3.so
#43 0x000055555571a557 in cfunction_call (func=<built-in method exec of QCoreApplication object at remote 0x7ffff7935f40>, args=(), kwargs=0x0) at Objects/methodobject.c:553
#44 0x00005555556d316e in _PyObject_MakeTpCall (tstate=tstate@entry=0x555555b378b0 <_PyRuntime+166000>, callable=callable@entry=<built-in method exec of QCoreApplication object at remote 0x7ffff7935f40>, args=args@entry=0x7ffff781e078, nargs=<optimized out>, keywords=keywords@entry=0x0) at Objects/call.c:214
#45 0x00005555556d32b1 in _PyObject_VectorcallTstate (tstate=0x555555b378b0 <_PyRuntime+166000>, callable=callable@entry=<built-in method exec of QCoreApplication object at remote 0x7ffff7935f40>, args=args@entry=0x7ffff781e078, nargsf=<optimized out>, kwnames=kwnames@entry=0x0) at ./Include/internal/pycore_call.h:90
#46 0x00005555556d3308 in PyObject_Vectorcall (callable=callable@entry=<built-in method exec of QCoreApplication object at remote 0x7ffff7935f40>, args=args@entry=0x7ffff781e078, nargsf=<optimized out>, kwnames=kwnames@entry=0x0) at Objects/call.c:299
#47 0x00005555557c14d2 in _PyEval_EvalFrameDefault (tstate=0x555555b378b0 <_PyRuntime+166000>, frame=0x7ffff781e020, throwflag=<optimized out>) at Python/ceval.c:4776
#48 0x00005555557c5c81 in _PyEval_EvalFrame (tstate=tstate@entry=0x555555b378b0 <_PyRuntime+166000>, frame=frame@entry=0x7ffff781e020, throwflag=throwflag@entry=0) at ./Include/internal/pycore_ceval.h:66
#49 0x00005555557c5d92 in _PyEval_Vector (tstate=tstate@entry=0x555555b378b0 <_PyRuntime+166000>, func=func@entry=0x7ffff789be30,
locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/florian/tmp/repro.py') at remote 0x7ffff773f030>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff78e2ed0>, '__file__': '/home/florian/tmp/repro.py', '__cached__': None, 'QUrl': <PyQt6.sip.wrappertype at remote 0x555555cfee50>, 'QTimer': <PyQt6.sip.wrappertype at remote 0x555555cfd520>, 'QCoreApplication': <PyQt6.sip.wrappertype at remote 0x555555cdd680>, 'app': <QCoreApplication() at remote 0x7ffff7935f40>, 'timer': <QTimer() at remote 0x7ffff4498520>}, args=args@entry=0x0, argcount=argcount@entry=0, kwnames=kwnames@entry=0x0) at Python/ceval.c:6396
#50 0x00005555557c5e9d in PyEval_EvalCode (co=co@entry=<code at remote 0x7ffff7778040>,
globals=globals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/florian/tmp/repro.py') at remote 0x7ffff773f030>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff78e2ed0>, '__file__': '/home/florian/tmp/repro.py', '__cached__': None, 'QUrl': <PyQt6.sip.wrappertype at remote 0x555555cfee50>, 'QTimer': <PyQt6.sip.wrappertype at remote 0x555555cfd520>, 'QCoreApplication': <PyQt6.sip.wrappertype at remote 0x555555cdd680>, 'app': <QCoreApplication() at remote 0x7ffff7935f40>, 'timer': <QTimer() at remote 0x7ffff4498520>},
locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/florian/tmp/repro.py') at remote 0x7ffff773f030>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff78e2ed0>, '__file__': '/home/florian/tmp/repro.py', '__cached__': None, 'QUrl': <PyQt6.sip.wrappertype at remote 0x555555cfee50>, 'QTimer': <PyQt6.sip.wrappertype at remote 0x555555cfd520>, 'QCoreApplication': <PyQt6.sip.wrappertype at remote 0x555555cdd680>, 'app': <QCoreApplication() at remote 0x7ffff7935f40>, 'timer': <QTimer() at remote 0x7ffff4498520>}) at Python/ceval.c:1157
#51 0x000055555580aaf4 in run_eval_code_obj (tstate=tstate@entry=0x555555b378b0 <_PyRuntime+166000>, co=co@entry=0x7ffff7778040,
globals=globals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/florian/tmp/repro.py') at remote 0x7ffff773f030>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff78e2ed0>, '__file__': '/home/florian/tmp/repro.py', '__cached__': None, 'QUrl': <PyQt6.sip.wrappertype at remote 0x555555cfee50>, 'QTimer': <PyQt6.sip.wrappertype at remote 0x555555cfd520>, 'QCoreApplication': <PyQt6.sip.wrappertype at remote 0x555555cdd680>, 'app': <QCoreApplication() at remote 0x7ffff7935f40>, 'timer': <QTimer() at remote 0x7ffff4498520>},
locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/florian/tmp/repro.py') at remote 0x7ffff773f030>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff78e2ed0>, '__file__': '/home/florian/tmp/repro.py', '__cached__': None, 'QUrl': <PyQt6.sip.wrappertype at remote 0x555555cfee50>, 'QTimer': <PyQt6.sip.wrappertype at remote 0x555555cfd520>, 'QCoreApplication': <PyQt6.sip.wrappertype at remote 0x555555cdd680>, 'app': <QCoreApplication() at remote 0x7ffff7935f40>, 'timer': <QTimer() at remote 0x7ffff4498520>}) at Python/pythonrun.c:1713
#52 0x000055555580abb1 in run_mod (mod=mod@entry=0x555555c1fd30, filename=filename@entry='/home/florian/tmp/repro.py',
globals=globals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/florian/tmp/repro.py') at remote 0x7ffff773f030>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff78e2ed0>, '__file__': '/home/florian/tmp/repro.py', '__cached__': None, 'QUrl': <PyQt6.sip.wrappertype at remote 0x555555cfee50>, 'QTimer': <PyQt6.sip.wrappertype at remote 0x555555cfd520>, 'QCoreApplication': <PyQt6.sip.wrappertype at remote 0x555555cdd680>, 'app': <QCoreApplication() at remote 0x7ffff7935f40>, 'timer': <QTimer() at remote 0x7ffff4498520>},
locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/florian/tmp/repro.py') at remote 0x7ffff773f030>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff78e2ed0>, '__file__': '/home/florian/tmp/repro.py', '__cached__': None, 'QUrl': <PyQt6.sip.wrappertype at remote 0x555555cfee50>, 'QTimer': <PyQt6.sip.wrappertype at remote 0x555555cfd520>, 'QCoreApplication': <PyQt6.sip.wrappertype at remote 0x555555cdd680>, 'app': <QCoreApplication() at remote 0x7ffff7935f40>, 'timer': <QTimer() at remote 0x7ffff4498520>}, flags=flags@entry=0x7fffffffc9d8, arena=arena@entry=0x7ffff776c640) at Python/pythonrun.c:1734
#53 0x000055555580ac79 in pyrun_file (fp=fp@entry=0x555555b804f0, filename=filename@entry='/home/florian/tmp/repro.py', start=start@entry=257,
globals=globals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/florian/tmp/repro.py') at remote 0x7ffff773f030>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff78e2ed0>, '__file__': '/home/florian/tmp/repro.py', '__cached__': None, 'QUrl': <PyQt6.sip.wrappertype at remote 0x555555cfee50>, 'QTimer': <PyQt6.sip.wrappertype at remote 0x555555cfd520>, 'QCoreApplication': <PyQt6.sip.wrappertype at remote 0x555555cdd680>, 'app': <QCoreApplication() at remote 0x7ffff7935f40>, 'timer': <QTimer() at remote 0x7ffff4498520>},
locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/florian/tmp/repro.py') at remote 0x7ffff773f030>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff78e2ed0>, '__file__': '/home/florian/tmp/repro.py', '__cached__': None, 'QUrl': <PyQt6.sip.wrappertype at remote 0x555555cfee50>, 'QTimer': <PyQt6.sip.wrappertype at remote 0x555555cfd520>, 'QCoreApplication': <PyQt6.sip.wrappertype at remote 0x555555cdd680>, 'app': <QCoreApplication() at remote 0x7ffff7935f40>, 'timer': <QTimer() at remote 0x7ffff4498520>}, closeit=closeit@entry=1, flags=0x7fffffffc9d8) at Python/pythonrun.c:1629
#54 0x000055555580d8cc in _PyRun_SimpleFileObject (fp=fp@entry=0x555555b804f0, filename=filename@entry='/home/florian/tmp/repro.py', closeit=closeit@entry=1, flags=flags@entry=0x7fffffffc9d8) at Python/pythonrun.c:439
#55 0x000055555580da80 in _PyRun_AnyFileObject (fp=fp@entry=0x555555b804f0, filename=filename@entry='/home/florian/tmp/repro.py', closeit=closeit@entry=1, flags=flags@entry=0x7fffffffc9d8) at Python/pythonrun.c:78
#56 0x000055555582b904 in pymain_run_file_obj (program_name=program_name@entry='/home/florian/tmp/.venv-retreat/bin/python3', filename=filename@entry='/home/florian/tmp/repro.py', skip_source_first_line=0) at Modules/main.c:353
#57 0x000055555582ba22 in pymain_run_file (config=config@entry=0x555555b1d910 <_PyRuntime+59600>) at Modules/main.c:372
#58 0x000055555582c191 in pymain_run_python (exitcode=exitcode@entry=0x7fffffffcb34) at Modules/main.c:592
#59 0x000055555582c3e6 in Py_RunMain () at Modules/main.c:671
#60 0x000055555582c460 in pymain_main (args=args@entry=0x7fffffffcb90) at Modules/main.c:701
#61 0x000055555582c52f in Py_BytesMain (argc=<optimized out>, argv=<optimized out>) at Modules/main.c:725
#62 0x0000555555643722 in main (argc=<optimized out>, argv=<optimized out>) at ./Programs/python.c:15
The bounds values in retreat:
(gdb) pp bounds
bounds =
autoderefcount="1",[
ar_start = <int> = {"0"}
ar_end = <int> = {"2"}
ar_line = <int> = {"6"}
opaque = <struct _opaque> = {"{...}"}
],<PyCodeAddressRange> = {"{...}"}
Args and locals for tb_displayline:
Details
(gdb) info args
tb = 0x7ffff44aa7b0
f = <_io.StringIO at remote 0x7ffff762b9d0>
filename = '/home/florian/tmp/repro.py'
lineno = 6
frame = Frame 0x7ffff4498600, for file /home/florian/tmp/repro.py, line 6, in <lambda> ()
name = <optimized out>
margin_indent = 0
margin = 0x5555558cc7df ""
(gdb) info locals
line = <optimized out>
res = 0
err = 0
truncation = -4
source_line = 'timer.timeout.connect(lambda: None)'
rc = 0
code_offset = <optimized out>
code = <optimized out>
start_line = 1435344176
end_line = 21845
start_col_byte_offset = 1436689024
end_col_byte_offset = 21845
__PRETTY_FUNCTION__ = "tb_displayline"
start_offset = <optimized out>
end_offset = <optimized out>
left_end_offset = 93824994118249
right_start_offset = -9223372036854775807
primary_error_char = 0x7ffff44ad900 ""
secondary_error_char = 0x10 <error: Cannot access memory at address 0x10>
Your environment
- CPython versions tested on: 3.11.0b1, current 3.11 branch
- Operating system and architecture: Arch Linux x86_64
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)release-blockertype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Activity
markshannon commentedon May 26, 2022
@The-Compiler can you reproduce this without PyQt6?
This might be a duplicate of #92597.
The-Compiler commentedon May 26, 2022
I haven't found a simpler reproducer so far, I'm afraid. Happy to re-test and report once there's a patch for that.
sweeneyde commentedon May 27, 2022
I replicated something like this by interrupting
test_threadingwith aCtrl+C, but this was very intermittent and hard to replicate.kumaraditya303 commentedon Jun 7, 2022
This is reproducible on Linux with a simple script and interrupting it.
Script:
pablogsal commentedon Jun 9, 2022
I can still reproduce this with 3.11.0b3
iritkatriel commentedon Jun 17, 2022
I tried to debug it and it looks like the innermost frame has lasti=0. So I think the exception is raised before anything happened in this frame, or something like this. Where in ceval.c does the KeyboardInterrupt get raised?
markshannon commentedon Jun 17, 2022
I'm unable to reproduce this.
If anyone can reproduce this running under gdb (or equivalent), could you post a traceback, please?
kumaraditya303 commentedon Jun 17, 2022
handle_signalsinceval.ccalls the default interrupt handler which unless overridden raises KeyboardInterrupt insignal_default_int_handler_implinsignalmodule.c.iritkatriel commentedon Jun 17, 2022
I can reproduce it on a Mac easily with Kumar's fibonacci script. I'll try to run in gdb.
iritkatriel commentedon Jun 17, 2022
Haven't managed to get there with a debugger, but I managed to see this:
The relevant "goto handle_eval_breaker;" is in the RESUME_QUICK opcode. If I print _PyInterpreterFrame_LASTI(frame); just before, it is indeed 0.
markshannon commentedon Jun 17, 2022
_PyInterpreterFrame_LASTI(frame) == 0should be fine. That just means we are executing the first instruction.iritkatriel commentedon Jun 17, 2022
So then we call to PyCode_Addr2Location from tb_displayline with addrq=0.
That calls
_PyCode_CheckLineNumberwithlasti=0; bounds->ar_start = -1; bounds->ar_end = 0;bounds->ar_end <= lasti. so we call_PyLineTable_NextAddressRange(bounds)which bumps bounds to (0,2), and we return to PyCode_Addr2Location (because nowbounds->ar_start > lastiis false).Then we call retreat() with bound->ar_start == 0, so the assertion fails.
iritkatriel commentedon Jun 17, 2022
If I change the assertion in retreat to
assert(bounds->ar_start >= 0);(instead of> 0) then it seems to work.After retreat ar_start can be negative, but I put
assert(bounds.ar_start >= 0);in PyCode_Addr2Location after advance_with_locations() and that holds.Do you remember why the assertion in retreat() has > rather than >=?
pythonGH-93249: relax overly struct assertion on bounds->ar_start
iritkatriel commentedon Jun 17, 2022
If it's just that the assertion is overly strict, then here's a PR to relax it: #93961
iritkatriel commentedon Jun 17, 2022
I'm writing a unit test for this, here is how to create such a traceback directly:
Output:
markshannon commentedon Jun 20, 2022
I don't remember, but looking at the code, it looks like
bounds->ar_start -= previous_code_delta(bounds);is not safe if the bounds is already pointing to the first entry.I think we need to change
previous_code_deltato check forbounds->ar_start == 0.I think adding this to
previous_code_deltashould fix it:GH-93249: relax overly strict assertion on bounds->ar_start (GH-93961)
pythonGH-93249: relax overly strict assertion on bounds->ar_start (py…
GH-93249: relax overly strict assertion on bounds->ar_start (GH-93961) (
Revert 30935 defer bpo45162 to 312 (#94285)