← 返回首页
Assertion failure on interrupt when catching exception group · Issue #102056 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

Assertion failure on interrupt when catching exception group #102056

New issue
New issue

Description

This (maybe too made-up and detached from reality) repro causes assertion failure when executed on current main (32df540).
On 3.11 it warns about "lost sys.stderr" and terminates.

import time import threading import _thread def f(): try: f() except RecursionError: f() def g(): try: raise ValueError() except* ValueError: f() def h(): time.sleep(1) _thread.interrupt_main() t = threading.Thread(target=h) t.start() g() t.join()

Output:

python: Objects/typeobject.c:4183: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed. Aborted (core dumped)

Stack trace:

#0 0x00007ffff7d3f34c in __pthread_kill_implementation () from /usr/lib/libc.so.6 #1 0x00007ffff7cf24b8 in raise () from /usr/lib/libc.so.6 #2 0x00007ffff7cdc534 in abort () from /usr/lib/libc.so.6 #3 0x00007ffff7cdc45c in __assert_fail_base.cold () from /usr/lib/libc.so.6 #4 0x00007ffff7ceb116 in __assert_fail () from /usr/lib/libc.so.6 #5 0x000055555574ecd9 in _PyType_Lookup (type=type@entry=0x555555be5430, name=name@entry=0x555555bb7c10 <_PyRuntime+334480>) at Objects/typeobject.c:4183 #6 0x00005555557319e3 in _PyObject_GenericGetAttrWithDict (obj=0x7ffff77a7c90, name=0x555555bb7c10 <_PyRuntime+334480>, dict=dict@entry=0x0, suppress=suppress@entry=1) at Objects/object.c:1266 #7 0x0000555555731d8d in _PyObject_LookupAttr (v=0x7ffff77a7c90, name=<optimized out>, result=result@entry=0x7ffffff40780) at Objects/object.c:933 #8 0x000055555582764c in print_exception_file_and_line (ctx=ctx@entry=0x7fffffffe270, value_p=value_p@entry=0x7ffffff40808) at Python/pythonrun.c:941 #9 0x0000555555827ed2 in print_exception (ctx=ctx@entry=0x7fffffffe270, value=value@entry=0x7ffff77a7c90) at Python/pythonrun.c:1209 #10 0x0000555555827fcc in print_exception_group (ctx=ctx@entry=0x7fffffffe270, value=value@entry=0x7ffff77a7c90) at Python/pythonrun.c:1377 #11 0x0000555555828418 in print_exception_recursive (ctx=ctx@entry=0x7fffffffe270, value=value@entry=0x7ffff77a7c90) at Python/pythonrun.c:1491 #12 0x0000555555828491 in print_chained (ctx=ctx@entry=0x7fffffffe270, value=value@entry=0x7ffff77a7c90, message=message@entry=0x55555594b200 <context_message> "During handling of the above exception, another exception occurred:\n", tag=tag@entry=0x5555558deda0 "context") at Python/pythonrun.c:1254 #13 0x000055555582868e in print_exception_cause_and_context (ctx=ctx@entry=0x7fffffffe270, value=value@entry=0x7ffff780e900) at Python/pythonrun.c:1344 #14 0x00005555558283d3 in print_exception_recursive (ctx=ctx@entry=0x7fffffffe270, value=value@entry=0x7ffff780e900) at Python/pythonrun.c:1482 #15 0x0000555555828491 in print_chained (ctx=ctx@entry=0x7fffffffe270, value=value@entry=0x7ffff780e900, message=message@entry=0x55555594b200 <context_message> "During handling of the above exception, another exception occurred:\n", tag=tag@entry=0x5555558deda0 "context") at Python/pythonrun.c:1254 ... #16186 0x000055555582868e in print_exception_cause_and_context (ctx=ctx@entry=0x7fffffffe270, value=value@entry=0x7ffff6be0ec0) at Python/pythonrun.c:1344 #16187 0x00005555558283d3 in print_exception_recursive (ctx=ctx@entry=0x7fffffffe270, value=value@entry=0x7ffff6be0ec0) at Python/pythonrun.c:1482 #16188 0x0000555555828491 in print_chained (ctx=ctx@entry=0x7fffffffe270, value=value@entry=0x7ffff6be0ec0, message=message@entry=0x55555594b200 <context_message> "During handling of the above exception, another exception occurred:\n", tag=tag@entry=0x5555558deda0 "context") at Python/pythonrun.c:1254 #16189 0x000055555582868e in print_exception_cause_and_context (ctx=ctx@entry=0x7fffffffe270, value=value@entry=0x7ffff6be0f30) at Python/pythonrun.c:1344 #16190 0x00005555558283d3 in print_exception_recursive (ctx=ctx@entry=0x7fffffffe270, value=value@entry=0x7ffff6be0f30) at Python/pythonrun.c:1482 #16191 0x0000555555828969 in _PyErr_Display (file=file@entry=0x7ffff79ba7b0, exception=exception@entry=0x555555a75160 <_PyExc_KeyboardInterrupt>, value=value@entry=0x7ffff6be0f30, tb=tb@entry=0x7ffff6c22ad0) at Python/pythonrun.c:1530 #16192 0x0000555555828ad3 in PyErr_Display (exception=0x555555a75160 <_PyExc_KeyboardInterrupt>, value=0x7ffff6be0f30, tb=0x7ffff6c22ad0) at Python/pythonrun.c:1562 #16193 0x0000555555835660 in sys_excepthook_impl (module=module@entry=0x7ffff7947f50, exctype=<optimized out>, value=<optimized out>, traceback=<optimized out>) at ./Python/sysmodule.c:748 #16194 0x00005555558356c6 in sys_excepthook (module=0x7ffff7947f50, args=args@entry=0x7fffffffe3f0, nargs=nargs@entry=3) at ./Python/clinic/sysmodule.c.h:102 #16195 0x000055555572c28c in cfunction_vectorcall_FASTCALL (func=0x7ffff7948470, args=0x7fffffffe3f0, nargsf=<optimized out>, kwnames=<optimized out>) at Objects/methodobject.c:422 #16196 0x00005555556e1aa0 in _PyObject_VectorcallTstate (tstate=0x555555bd8808 <_PyRuntime+468616>, callable=callable@entry=0x7ffff7948470, args=0x7fffffffe3f0, args@entry=0x7fffffffe360, nargsf=nargsf@entry=3, kwnames=kwnames@entry=0x0) at ./Include/internal/pycore_call.h:92 #16197 0x00005555556e1b90 in _PyObject_FastCallTstate (nargs=3, args=0x7fffffffe360, func=0x7ffff7948470, tstate=<optimized out>) at ./Include/internal/pycore_call.h:116 #16198 _PyObject_FastCall (func=func@entry=0x7ffff7948470, args=args@entry=0x7fffffffe3f0, nargs=nargs@entry=3) at Objects/call.c:310 #16199 0x0000555555828c2b in _PyErr_PrintEx (tstate=0x555555bd8808 <_PyRuntime+468616>, set_sys_last_vars=set_sys_last_vars@entry=1) at Python/pythonrun.c:813 #16200 0x0000555555828eb1 in PyErr_PrintEx (set_sys_last_vars=set_sys_last_vars@entry=1) at Python/pythonrun.c:861 #16201 0x0000555555828ec1 in PyErr_Print () at Python/pythonrun.c:867 #16202 0x00005555558293ab in _PyRun_SimpleFileObject (fp=fp@entry=0x555555bdb530, filename=filename@entry=0x7ffff77adbc0, closeit=closeit@entry=1, flags=flags@entry=0x7fffffffe508) at Python/pythonrun.c:439 #16203 0x000055555582951d in _PyRun_AnyFileObject (fp=fp@entry=0x555555bdb530, filename=filename@entry=0x7ffff77adbc0, closeit=closeit@entry=1, flags=flags@entry=0x7fffffffe508) at Python/pythonrun.c:78 #16204 0x00005555558487a5 in pymain_run_file_obj (program_name=program_name@entry=0x7ffff77c7370, filename=filename@entry=0x7ffff77adbc0, skip_source_first_line=0) at Modules/main.c:360 #16205 0x00005555558488cd in pymain_run_file (config=config@entry=0x555555bbd3c0 <_PyRuntime+356928>) at Modules/main.c:379 #16206 0x0000555555849063 in pymain_run_python (exitcode=exitcode@entry=0x7fffffffe684) at Modules/main.c:610 #16207 0x000055555584930f in Py_RunMain () at Modules/main.c:689 #16208 0x0000555555849386 in pymain_main (args=args@entry=0x7fffffffe6e0) at Modules/main.c:719 #16209 0x000055555584944c in Py_BytesMain (argc=<optimized out>, argv=<optimized out>) at Modules/main.c:743 #16210 0x0000555555651772 in main (argc=<optimized out>, argv=<optimized out>) at ./Programs/python.c:15

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

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

  • Open in GitHub Copilot app

Footer

© 2026 GitHub, Inc.