Skip to content

Crash in test_sys_setprofile if it follows test_sys_settrace #109371

Closed
@serhiy-storchaka

Description

@serhiy-storchaka

Crash report

test_reentrancy in test_sys_setprofile crashes if it follows test_sys_settrace runned in the same process.

The fastest reproducer:

$ ./python -m test -v test_sys_settrace test_sys_setprofile -m test_sys_settrace -m test_reentrancy
...
test_reentrancy (test.test_sys_setprofile.TestEdgeCases.test_reentrancy) ... python: Python/instrumentation.c:662: instrument: Assertion `!is_instrumented(opcode)' failed.
Fatal Python error: Aborted

Current thread 0x00007f7bc76e9740 (most recent call first):
  File "/home/serhiy/py/cpython/Lib/unittest/case.py", line 873 in _baseAssertEqual
  File "/home/serhiy/py/cpython/Lib/unittest/case.py", line 885 in assertEqual
  File "/home/serhiy/py/cpython/Lib/test/test_sys_setprofile.py", line 440 in test_reentrancy
  File "/home/serhiy/py/cpython/Lib/unittest/case.py", line 589 in _callTestMethod
  File "/home/serhiy/py/cpython/Lib/unittest/case.py", line 634 in run
  File "/home/serhiy/py/cpython/Lib/unittest/case.py", line 690 in __call__
  File "/home/serhiy/py/cpython/Lib/unittest/suite.py", line 122 in run
  File "/home/serhiy/py/cpython/Lib/unittest/suite.py", line 84 in __call__
  File "/home/serhiy/py/cpython/Lib/unittest/suite.py", line 122 in run
  File "/home/serhiy/py/cpython/Lib/unittest/suite.py", line 84 in __call__
  File "/home/serhiy/py/cpython/Lib/unittest/suite.py", line 122 in run
  File "/home/serhiy/py/cpython/Lib/unittest/suite.py", line 84 in __call__
  File "/home/serhiy/py/cpython/Lib/unittest/runner.py", line 240 in run
  File "/home/serhiy/py/cpython/Lib/test/support/__init__.py", line 1137 in _run_suite
  File "/home/serhiy/py/cpython/Lib/test/support/__init__.py", line 1264 in run_unittest
  File "/home/serhiy/py/cpython/Lib/test/libregrtest/single.py", line 36 in run_unittest
  File "/home/serhiy/py/cpython/Lib/test/libregrtest/single.py", line 90 in test_func
  File "/home/serhiy/py/cpython/Lib/test/libregrtest/single.py", line 48 in regrtest_runner
  File "/home/serhiy/py/cpython/Lib/test/libregrtest/single.py", line 93 in _load_run_test
  File "/home/serhiy/py/cpython/Lib/test/libregrtest/single.py", line 136 in _runtest_env_changed_exc
  File "/home/serhiy/py/cpython/Lib/test/libregrtest/single.py", line 236 in _runtest
  File "/home/serhiy/py/cpython/Lib/test/libregrtest/single.py", line 264 in run_single_test
  File "/home/serhiy/py/cpython/Lib/test/libregrtest/main.py", line 283 in run_test
  File "/home/serhiy/py/cpython/Lib/test/libregrtest/main.py", line 318 in run_tests_sequentially
  File "/home/serhiy/py/cpython/Lib/test/libregrtest/main.py", line 444 in _run_tests
  File "/home/serhiy/py/cpython/Lib/test/libregrtest/main.py", line 474 in run_tests
  File "/home/serhiy/py/cpython/Lib/test/libregrtest/main.py", line 503 in main
  File "/home/serhiy/py/cpython/Lib/test/libregrtest/main.py", line 511 in main
  File "/home/serhiy/py/cpython/Lib/test/__main__.py", line 2 in <module>
  File "/home/serhiy/py/cpython/Lib/runpy.py", line 88 in _run_code
  File "/home/serhiy/py/cpython/Lib/runpy.py", line 198 in _run_module_as_main

Extension modules: _testcapi (total: 1)
Aborted (core dumped)

Stacktrace:

#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=140737350489920) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=140737350489920) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=140737350489920, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x00007ffff7cca476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x00007ffff7cb07f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x00007ffff7cb071b in __assert_fail_base (fmt=0x7ffff7e65150 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x5555559ce388 "!is_instrumented(opcode)", 
    file=0x5555559ce260 "Python/instrumentation.c", line=662, function=<optimized out>) at ./assert/assert.c:92
#6  0x00007ffff7cc1e96 in __GI___assert_fail (assertion=assertion@entry=0x5555559ce388 "!is_instrumented(opcode)", file=file@entry=0x5555559ce260 "Python/instrumentation.c", 
    line=line@entry=662, function=function@entry=0x5555559cf120 <__PRETTY_FUNCTION__.9> "instrument") at ./assert/assert.c:101
#7  0x0000555555850f1d in instrument (code=code@entry=0x7ffff746f0d0, i=i@entry=54) at Python/instrumentation.c:662
#8  0x0000555555850fec in add_tools (code=code@entry=0x7ffff746f0d0, offset=offset@entry=54, event=event@entry=2, tools=tools@entry=64) at Python/instrumentation.c:793
#9  0x0000555555854473 in _Py_Instrument (code=0x7ffff746f0d0, interp=<optimized out>) at Python/instrumentation.c:1618
#10 0x00005555557d3899 in _PyEval_EvalFrameDefault (tstate=tstate@entry=0x555555c0e818 <_PyRuntime+508728>, frame=0x7ffff7b413c0, throwflag=throwflag@entry=0)
    at Python/generated_cases.c.h:47
#11 0x00005555557f45df in _PyEval_EvalFrame (throwflag=0, frame=<optimized out>, tstate=0x555555c0e818 <_PyRuntime+508728>) at ./Include/internal/pycore_ceval.h:107
#12 _PyEval_Vector (tstate=0x555555c0e818 <_PyRuntime+508728>, func=0x7ffff7180dd0, locals=locals@entry=0x0, args=0x7fffffffb6b0, argcount=2, kwnames=0x0) at Python/ceval.c:1632
...

All other tests in test_sys_setprofile do not crash. Reproduced on 3.12+. 3.11 does not have test_reentrancy.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)testsTests in the Lib/test dirtype-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