Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_sys_settrace segfaults on main #109143

Closed
JelleZijlstra opened this issue Sep 8, 2023 · 4 comments
Closed

test_sys_settrace segfaults on main #109143

JelleZijlstra opened this issue Sep 8, 2023 · 4 comments
Labels
3.13 bugs and security fixes type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@JelleZijlstra
Copy link
Member

JelleZijlstra commented Sep 8, 2023

Crash report

On clean main:

% ./python.exe -m test -R 3:3 test_sys_settrace
Raised RLIMIT_NOFILE: 256 -> 1024
0:00:00 load avg: 2.44 Run tests sequentially
0:00:00 load avg: 2.44 [1/1] test_sys_settrace
beginning 6 repetitions
123456
...Fatal Python error: Segmentation fault

Current thread 0x00000001fd5ade00 (most recent call first):
  File "/Users/jelle/py/cpython/Lib/test/test_sys_settrace.py", line 1912 in trace
  File "/Users/jelle/py/cpython/Lib/test/test_sys_settrace.py", line 2162 in test_jump_backwards_into_while_block
  File "/Users/jelle/py/cpython/Lib/test/test_sys_settrace.py", line 1975 in run_test
  File "/Users/jelle/py/cpython/Lib/test/test_sys_settrace.py", line 2008 in test
  File "/Users/jelle/py/cpython/Lib/unittest/case.py", line 589 in _callTestMethod
  File "/Users/jelle/py/cpython/Lib/unittest/case.py", line 634 in run
  File "/Users/jelle/py/cpython/Lib/unittest/case.py", line 690 in __call__
  File "/Users/jelle/py/cpython/Lib/unittest/suite.py", line 122 in run
  File "/Users/jelle/py/cpython/Lib/unittest/suite.py", line 84 in __call__
  File "/Users/jelle/py/cpython/Lib/unittest/suite.py", line 122 in run
  File "/Users/jelle/py/cpython/Lib/unittest/suite.py", line 84 in __call__
  File "/Users/jelle/py/cpython/Lib/unittest/suite.py", line 122 in run
  File "/Users/jelle/py/cpython/Lib/unittest/suite.py", line 84 in __call__
  File "/Users/jelle/py/cpython/Lib/test/support/testresult.py", line 146 in run
  File "/Users/jelle/py/cpython/Lib/test/support/__init__.py", line 1141 in _run_suite
  File "/Users/jelle/py/cpython/Lib/test/support/__init__.py", line 1268 in run_unittest
  File "/Users/jelle/py/cpython/Lib/test/libregrtest/runtest.py", line 393 in run_unittest
  File "/Users/jelle/py/cpython/Lib/test/libregrtest/runtest.py", line 447 in test_func
  File "/Users/jelle/py/cpython/Lib/test/libregrtest/refleak.py", line 91 in dash_R
  File "/Users/jelle/py/cpython/Lib/test/libregrtest/runtest.py", line 405 in regrtest_runner
  File "/Users/jelle/py/cpython/Lib/test/libregrtest/runtest.py", line 451 in _load_run_test
  File "/Users/jelle/py/cpython/Lib/test/libregrtest/runtest.py", line 491 in _runtest_env_changed_exc
  File "/Users/jelle/py/cpython/Lib/test/libregrtest/runtest.py", line 348 in _runtest
  File "/Users/jelle/py/cpython/Lib/test/libregrtest/runtest.py", line 375 in runtest
  File "/Users/jelle/py/cpython/Lib/test/libregrtest/main.py", line 462 in run_test
  File "/Users/jelle/py/cpython/Lib/test/libregrtest/main.py", line 495 in run_tests_sequentially
  File "/Users/jelle/py/cpython/Lib/test/libregrtest/main.py", line 632 in run_tests
  File "/Users/jelle/py/cpython/Lib/test/libregrtest/main.py", line 855 in action_run_tests
  File "/Users/jelle/py/cpython/Lib/test/libregrtest/main.py", line 883 in _main
  File "/Users/jelle/py/cpython/Lib/test/libregrtest/main.py", line 822 in main
  File "/Users/jelle/py/cpython/Lib/test/libregrtest/main.py", line 891 in main
  File "/Users/jelle/py/cpython/Lib/test/__main__.py", line 2 in <module>
  File "/Users/jelle/py/cpython/Lib/runpy.py", line 88 in _run_code
  File "/Users/jelle/py/cpython/Lib/runpy.py", line 198 in _run_module_as_main

Extension modules: _testcapi (total: 1)
zsh: segmentation fault  ./python.exe -m test -R 3:3 test_sys_settrace

I saw this in buildbots on my PR #109123 but it also reproduces on main for me locally.

Stack trace:

Process 47388 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
    frame #0: 0x000000010008c140 python.exe`code_richcompare(self=0x00000001025453f0, other=0x00000001025453f0, op=3) at codeobject.c:1808:39 [opt]
   1805	
   1806	        if (co_code == ENTER_EXECUTOR) {
   1807	            const int exec_index = co_arg;
-> 1808	            _PyExecutorObject *exec = co->co_executors->executors[exec_index];
   1809	            co_code = exec->vm_data.opcode;
   1810	            co_arg = exec->vm_data.oparg;
   1811	        }
Target 0: (python.exe) stopped.
warning: python.exe was compiled with optimization - stepping may behave oddly; variables may not be available.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
  * frame #0: 0x000000010008c140 python.exe`code_richcompare(self=0x00000001025453f0, other=0x00000001025453f0, op=3) at codeobject.c:1808:39 [opt]
    frame #1: 0x00000001000d2b14 python.exe`do_richcompare(tstate=0x00000001004ea308, v=0x00000001025453f0, w=0x00000001025453f0, op=3) at object.c:787:15 [opt]
    frame #2: 0x00000001000d2a64 python.exe`PyObject_RichCompare(v=0x00000001025453f0, w=0x00000001025453f0, op=3) at object.c:836:21 [opt]
    frame #3: 0x0000000100168354 python.exe`_PyEval_EvalFrameDefault(tstate=<unavailable>, frame=<unavailable>, throwflag=<unavailable>) at generated_cases.c.h:2757:19 [opt]
    frame #4: 0x000000010015e0b4 python.exe`_PyEval_EvalFrame(tstate=<unavailable>, frame=<unavailable>, throwflag=<unavailable>) at pycore_ceval.h:107:16 [opt]
    frame #5: 0x000000010015e04c python.exe`_PyEval_Vector(tstate=0x00000001004ea308, func=0x00000001036c2bd0, locals=0x0000000000000000, args=0x000000016fdfc340, argcount=4, kwnames=0x0000000000000000) at ceval.c:1632:12 [opt]
    frame #6: 0x0000000100086758 python.exe`_PyFunction_Vectorcall(func=0x00000001036c2bd0, stack=0x000000016fdfc340, nargsf=<unavailable>, kwnames=0x0000000000000000) at call.c:0:45 [opt]
    frame #7: 0x00000001000894d8 python.exe`_PyObject_VectorcallTstate(tstate=0x00000001004ea308, callable=0x00000001036c2bd0, args=0x000000016fdfc340, nargsf=4, kwnames=0x0000000000000000) at pycore_call.h:187:11 [opt]
    frame #8: 0x000000010008898c python.exe`method_vectorcall(method=<unavailable>, args=0x000000016fdfc3f0, nargsf=<unavailable>, kwnames=0x0000000000000000) at classobject.c:92:18 [opt]
    frame #9: 0x00000001001dfbc0 python.exe`_PyObject_VectorcallTstate(tstate=0x00000001004ea308, callable=0x000000010372cc50, args=0x000000016fdfc3f0, nargsf=3, kwnames=0x0000000000000000) at pycore_call.h:187:11 [opt]
    frame #10: 0x00000001001e1c34 python.exe`call_trampoline(tstate=0x00000001004ea308, callback=0x000000010372cc50, frame=0x0000000103650ef0, what=2, arg=<unavailable>) at sysmodule.c:1005:24 [opt]
    frame #11: 0x00000001001e1d8c python.exe`trace_trampoline(self=<unavailable>, frame=0x0000000103650ef0, what=2, arg=0x0000000100451758) at sysmodule.c:1042:24 [opt]
    frame #12: 0x00000001001b4c24 python.exe`_Py_call_instrumentation_line(tstate=0x00000001004ea308, frame=<unavailable>, instr=<unavailable>, prev=<unavailable>) at instrumentation.c:1173:27 [opt]

The problem is that co->co_executors is NULL. This line blames to @corona10's PR #108165.

@JelleZijlstra JelleZijlstra added type-crash A hard crash of the interpreter, possibly with a core dump 3.13 bugs and security fixes labels Sep 8, 2023
@corona10
Copy link
Member

corona10 commented Sep 8, 2023

Would you like to check that #109107 will fix this issue?

@corona10
Copy link
Member

corona10 commented Sep 8, 2023

With fix, I check that it will solve the issue

 ./python.exe -m test -R 3:3 test_sys_settrace
Raised RLIMIT_NOFILE: 256 -> 1024
0:00:00 load avg: 4.02 Run tests sequentially
0:00:00 load avg: 4.02 [1/1] test_sys_settrace
beginning 6 repetitions
123456
......

== Tests result: SUCCESS ==

1 test OK.

Total duration: 21.9 sec
Total tests: run=439 skipped=1
Total test files: run=1/1
Result: SUCCESS

I think that we can close the issue as duplicated.

@JelleZijlstra
Copy link
Member Author

Thanks, this is a duplicate of #109052 so I'll close this issue. I'm compiling the PR now.

@JelleZijlstra JelleZijlstra closed this as not planned Won't fix, can't repro, duplicate, stale Sep 8, 2023
@corona10
Copy link
Member

corona10 commented Sep 8, 2023

For clarification, the PR #108165 was verified that passed the test at that moment because I always check the leak test in the local environment before I submit the PR :)

It looks like the issue is raised with multiple causes, and the first triggered commit was 6f3c138 and this commit is not a root cause.
This is the same conclusion with @vstinner

I investigated the first commit with git bisecting :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

No branches or pull requests

2 participants