Skip to content

test_tracemalloc: test_tracemalloc_track_race() crashs on GHA iOS CI #150485

Open

Description

@vstinner

Crash report

iOS: https://github.com/python/cpython/actions/runs/26457870719/job/77897032289?pr=150441

This issue is likely the same as issue gh-143143, but I'm not 100% sure so I created a separated issue.

    0:11:19 load avg: 2.79 [435/505] test_tracemalloc
  Fatal Python error: Segmentation fault
  
  Current thread 0x0000000322193000 (most recent call first):
  
  Thread 0x0000000321187000 (most recent call first):
  
  Thread 0x000000032017b000 (most recent call first):
  
  (...)
  
  Thread 0x00000003100bb000 (most recent call first):
  
  <freed thread state>
  
  Current thread's C stack trace (most recent call first):
    Binary file "/Users/runner/work/cpython/cpython/cross-build/iOS-testbed.1779809388208/DerivedData/Build/Products/Debug-iphonesimulator/Python.framework/Python", at _Py_DumpStack+0x44 [0x102407804]
    Binary file "/Users/runner/work/cpython/cpython/cross-build/iOS-testbed.1779809388208/DerivedData/Build/Products/Debug-iphonesimulator/Python.framework/Python", at faulthandler_fatal_error+0x264 [0x10241e4a0]
    Binary file "/usr/lib/system/libsystem_platform.dylib", at _sigtramp+0x34 [0x100a6f7e0]
    Binary file "/Users/runner/work/cpython/cpython/cross-build/iOS-testbed.1779809388208/DerivedData/Build/Products/Debug-iphonesimulator/Python.framework/Python", at PyGILState_Ensure+0xf8 [0x1023eab50]
    Binary file "/Users/runner/work/cpython/cpython/cross-build/iOS-testbed.1779809388208/DerivedData/Build/Products/Debug-iphonesimulator/Python.framework/Python", at PyGILState_Ensure+0xf8 [0x1023eab50]
    Binary file "/Users/runner/work/cpython/cpython/cross-build/iOS-testbed.1779809388208/DerivedData/Build/Products/Debug-iphonesimulator/Python.framework/Python", at tracemalloc_alloc+0xa8 [0x1024097a4]
    Binary file "/Users/runner/work/cpython/cpython/cross-build/iOS-testbed.1779809388208/DerivedData/Build/Products/Debug-iphonesimulator/Python.framework/Python", at PyGILState_Ensure+0x58 [0x1023eaab0]
    Binary file "/Users/runner/work/cpython/cpython/cross-build/iOS-testbed.1779809388208/DerivedData/Build/Products/Debug-iphonesimulator/Python.framework/Python", at PyTraceMalloc_Track+0x34 [0x1024088ec]
    Binary file "/Users/runner/Library/Developer/CoreSimulator/Devices/D3F1CE55-196D-4DC8-9D1F-6D2D3AB3D118/data/Containers/Bundle/Application/130788EC-7B24-4534-8FF0-89C57EC65B80/iOSTestbed.app/Frameworks/_testcapi.framework/_testcapi", at tracemalloc_track_race_thread+0x20 [0x106f251b0]
    (...)
  
  Extension modules: _testcapi, _testinternalcapi, _testlimitedcapi, _testmultiphase, _testbuffer, _ctypes_test, xxsubtype, _testsinglephase_basic_wrapper, _testsinglephase_basic_copy, _testsinglephase_with_reinit, _testsinglephase_with_state, _test_non_isolated, _test_shared_gil_only, _test_no_multiple_interpreter_slot, _testsinglephase (total: 15)
  
  Restarting after unexpected exit, crash, or test timeout in -[TestbedTests testPython]; summary will include totals from previous launches.

Activity

  1. added
    testsTests in the Lib/test dir
    type-crashA hard crash of the interpreter, possibly with a core dump
    on May 26, 2026
  2. kumaraditya303 commented on Jun 1, 2026

    @kumaraditya303
    Contributor

    Based on the investigation in #143143, I think we should change the test itself, starting or stopping tracemalloc is not safe at runtime and won't be safe because it affects raw allocator as well which is not synchronized.

  3. vstinner commented on Jun 2, 2026

    @vstinner
    MemberAuthor

    The test does also crash randomly on Android. Example on aarch64 Android 3.13: https://buildbot.python.org/#/builders/1590/builds/1395

    The traceback starts with test_tracemalloc_track_race():

    0:09:33 [413/481] test_tracemalloc
    W/native.stderr: exiting due to SIG_DFL handler for signal 11, ucontext 0x732c549e20
    F/libc: exiting due to SIG_DFL handler for signal 11, ucontext 0x732c549e20
    W/native.stderr: Fatal Python error: 
    W/native.stderr: Aborted
    W/native.stderr: 
    W/native.stderr: Thread 0x
    W/native.stderr: 0000007338aff4f8
    W/native.stderr:  (most recent call first):
    W/native.stderr:   File 
    W/native.stderr: "
    W/native.stderr: /data/user/0/org.python.testbed/files/python/lib/python3.13/test/test_tracemalloc.py
    W/native.stderr: "
    W/native.stderr: , line 
    W/native.stderr: 1119
    W/native.stderr:  in 
    W/native.stderr: test_tracemalloc_track_race
    W/native.stderr: 
    W/native.stderr:   File 
    W/native.stderr: "
    W/native.stderr: /data/user/0/org.python.testbed/files/python/lib/python3.13/unittest/case.py
    W/native.stderr: "
    W/native.stderr: , line 
    W/native.stderr: 606
    W/native.stderr:  in 
    W/native.stderr: _callTestMethod
    W/native.stderr: 
    W/native.stderr:   File 
    W/native.stderr: "
    W/native.stderr: /data/user/0/org.python.testbed/files/python/lib/python3.13/unittest/case.py
    W/native.stderr: "
    W/native.stderr: , line 
    W/native.stderr: 651
    W/native.stderr:  in 
    W/native.stderr: run
    W/native.stderr: 
    W/native.stderr:   File 
    W/native.stderr: "
    W/native.stderr: /data/user/0/org.python.testbed/files/python/lib/python3.13/unittest/case.py
    W/native.stderr: "
    W/native.stderr: , line 
    W/native.stderr: 707
    W/native.stderr:  in 
    W/native.stderr: __call__
    W/native.stderr: 
    W/native.stderr:   File 
    W/native.stderr: "
    W/native.stderr: /data/user/0/org.python.testbed/files/python/lib/python3.13/unittest/suite.py
    W/native.stderr: "
    W/native.stderr: , line 
    W/native.stderr: 122
    W/native.stderr:  in 
    W/native.stderr: run
      File "/data/user/0/org.python.testbed/files/python/lib/python3.13/unittest/suite.py", line 84 in __call__
      File "/data/user/0/org.python.testbed/files/python/lib/python3.13/unittest/suite.py", line 122 in run
      File "/data/user/0/org.python.testbed/files/python/lib/python3.13/unittest/suite.py", line 84 in __call__
      File "/data/user/0/org.python.testbed/files/python/lib/python3.13/unittest/runner.py", line 240 in run
      File "/data/user/0/org.python.testbed/files/python/lib/python3.13/test/libregrtest/single.py", line 57 in _run_suite
      File "/data/user/0/org.python.testbed/files/python/lib/python3.13/test/libregrtest/single.py", line 37 in run_unittest
      File "/data/user/0/org.python.testbed/files/python/lib/python3.13/test/libregrtest/single.py", line 135 in test_func
      File "/data/user/0/org.python.testbed/files/python/lib/python3.13/test/libregrtest/single.py", line 91 in regrtest_runner
      File "/data/user/0/org.python.testbed/files/python/lib/python3.13/test/libregrtest/single.py", line 138 in _load_run_test
      File "/data/user/0/org.python.testbed/files/python/lib/python3.13/test/libregrtest/single.py", line 181 in _runtest_env_changed_exc
      File "/data/user/0/org.python.testbed/files/python/lib/python3.13/test/libregrtest/single.py", line 266 in _runtest
      File "/data/user/0/org.python.testbed/files/python/lib/python3.13/test/libregrtest/single.py", line 310 in run_single_test
      File "/data/user/0/org.python.testbed/files/python/lib/python3.13/test/libregrtest/main.py", line 371 in run_test
      File "/data/user/0/org.python.testbed/files/python/lib/python3.13/test/libregrtest/main.py", line 401 in run_tests_sequentially
      File "/data/user/0/org.python.testbed/files/python/lib/python3.13/test/libregrtest/main.py", line 551 in _run_tests
      File "/data/user/0/org.python.testbed/files/python/lib/python3.13/test/libregrtest/main.py", line 586 in run_tests
      File "/data/user/0/org.python.testbed/files/python/lib/python3.13/test/libregrtest/main.py", line 767 in main
      File "/data/user/0/org.python.testbed/files/python/lib/python3.13/test/libregrtest/main.py", line 775 in main
      File "/data/user/0/org.python.testbed/files/python/lib/python3.13/test/__main__.py", line 2 in <module>
      File "<frozen runpy>", line 88 in _run_code
      File "<frozen runpy>", line 203 in _run_module_as_main
    W/native.stderr: Extension modules: 
    W/native.stderr: _testcapi
    W/native.stderr: , _testinternalcapi, _testlimitedcapi, _testbuffer, _ctypes_test
    W/native.stderr: , xxsubtype, _testexternalinspection
    W/native.stderr: , _testsinglephase_basic_wrapper, _testsinglephase_basic_copy, _testsinglephase_with_reinit, _testsinglephase_with_state, _test_non_isolated, _test_shared_gil_only, _test_no_multiple_interpreter_slot, _testmultiphase
    W/native.stderr:  (total: 15)
    F/libc: Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 9309 (.python.testbed), pid 1638 (.python.testbed)
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-androidOS-iosinterpreter-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