Closed
Description
Crash report
What happened?
When a _lsprof.Profiler
is enabled and a TypeError
is raised from mismatching descriptor and target, a Fatal Python error happens due to _ccall_callback
returning a result with an exception set:
import _lsprof
prof = _lsprof.Profiler()
prof.enable()
def mismatch(first, second):
first.find(second())
mismatch(bytes, str)
# mismatch(str, bytes)
# mismatch(str, list)
Fatal Python error: _Py_CheckFunctionResult: a function returned a result with an exception set
Python runtime state: initialized
TypeError: descriptor 'find' for 'bytes' objects doesn't apply to a 'str' object
The above exception was the direct cause of the following exception:
SystemError: <built-in method _ccall_callback of _lsprof.Profiler object at 0x20000922f10> returned a result with an exception set
Stack (most recent call first):
File "/mnt/c/Users/ddini/crashers/main/cProfile-fatal_python_error-abort/source2.py", line 7 in mismatch
File "/mnt/c/Users/ddini/crashers/main/cProfile-fatal_python_error-abort/source2.py", line 9 in <module>
Program received signal SIGABRT, Aborted.
Backtrace:
#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 0x000055555590ba45 in fatal_error_exit (status=<optimized out>) at Python/pylifecycle.c:3140
#6 0x000055555591879a in fatal_error (fd=2, header=header@entry=1,
prefix=prefix@entry=0x555555a27b40 <__func__.23> "_Py_CheckFunctionResult",
msg=msg@entry=0x555555a275a0 "a function returned a result with an exception set", status=status@entry=-1)
at Python/pylifecycle.c:3356
#7 0x000055555591880c in _Py_FatalErrorFunc (func=func@entry=0x555555a27b40 <__func__.23> "_Py_CheckFunctionResult",
msg=msg@entry=0x555555a275a0 "a function returned a result with an exception set") at Python/pylifecycle.c:3372
#8 0x000055555567dfe8 in _Py_CheckFunctionResult (tstate=tstate@entry=0x555555cd6498 <_PyRuntime+361432>,
callable=callable@entry=<built-in method _ccall_callback of _lsprof.Profiler object at remote 0x20000922f10>,
result=<optimized out>, where=where@entry=0x0) at Objects/call.c:65
#9 0x00005555558f1298 in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=9223372036854775812, args=0x7fffffffd478,
callable=<built-in method _ccall_callback of _lsprof.Profiler object at remote 0x20000922f10>,
tstate=0x555555cd6498 <_PyRuntime+361432>) at ./Include/internal/pycore_call.h:170
#10 call_one_instrument (interp=interp@entry=0x555555c9de40 <_PyRuntime+130432>,
tstate=tstate@entry=0x555555cd6498 <_PyRuntime+361432>, args=args@entry=0x7fffffffd478,
nargsf=nargsf@entry=9223372036854775812, tool=tool@entry=2 '\002', event=event@entry=4) at Python/instrumentation.c:985
#11 0x00005555558f373f in call_instrumentation_vector (instr=instr@entry=0x200009f241c,
tstate=tstate@entry=0x555555cd6498 <_PyRuntime+361432>, event=event@entry=4, frame=frame@entry=0x7ffff7fb0090,
arg2=arg2@entry=0x200009f241c, nargs=<optimized out>, nargs@entry=4, args=0x7fffffffd470) at Python/instrumentation.c:1172
#12 0x00005555558f5d65 in _Py_call_instrumentation_2args (tstate=tstate@entry=0x555555cd6498 <_PyRuntime+361432>,
event=event@entry=4, frame=frame@entry=0x7ffff7fb0090, instr=instr@entry=0x200009f241c, arg0=<optimized out>,
arg1=<optimized out>) at Python/instrumentation.c:1227
#13 0x0000555555867263 in _PyEval_EvalFrameDefault (tstate=tstate@entry=0x555555cd6498 <_PyRuntime+361432>, frame=0x7ffff7fb0090,
frame@entry=0x7ffff7fb0020, throwflag=throwflag@entry=0) at Python/generated_cases.c.h:6122
#14 0x00005555558859f2 in _PyEval_EvalFrame (throwflag=0, frame=0x7ffff7fb0020, tstate=0x555555cd6498 <_PyRuntime+361432>)
at ./Include/internal/pycore_ceval.h:119
Found using fusil by @vstinner.
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:be2d2181e62, Mar 31 2025, 07:30:17) [GCC 11.4.0]