Skip to content

profiling SEGV with --mode=gil with freethreading #140739

@dimaqq

Description

@dimaqq

Bug report

Bug description:

Command:
sudo -E time env PYTHONPATH=src python -m profiling.sampling -a --sort-tottime --flamegraph --mode=gil -d 999 test/test_unit.py 100 100

Version:
Python 3.15.0a1 free-threading build (main, Oct 14 2025, 21:34:02) [Clang 20.1.4 ] on darwin

macOS:
Darwin kot.local 24.6.0 Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:51 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T8112 arm64

Workload summary:

with concurrent.futures.ThreadPoolExecutor() as executor:
    ...
    executor.map(some_func, [arg1s], [arg2s], ...)

Workload needs to be large enough and run long enough for the crash to happen.

  • large .map() arity (no issue with 10, crashes with 100)
  • more than several seconds long

The profiling "controller" process appears to crash, leaving the "workload" process running:

Output:

Resetting... [....................................................................................................]
Reset [0...................................................................................................]
0: [0001110001010101111110001110010101010101001010101000111101010111000111000101010111111000111001010101] --> 0
0: [0...................................................................................................]
0: [0011010101001100010111010000010111000101010000000100000100010100010101100000110011000101011001000001] --> 1
1: [0...................................................................................................]
1: [0011101000000000100110001000010001000001010000000100000010010000010100100001010011000001001100000010] --> 2
2: [0...................................................................................................]
2: [0001010000000010000000000000110000000011000000001100000010100000010110110000011000000011101100000000] --> 3
time: command terminated abnormally
        2.56 real         1.39 user         1.05 sys
fish: Job 1, 'sudo -E time env PYTHONPATH=src…' terminated by signal SIGSEGV (Address boundary error)
(jgol-peer) 🦐/c/j/peer (main) [SIGSEGV]> 3: [0...................................................................................................]
3: [0000100000000010000000000000110000000100000000000000000010000000000001000000000100000010100000000100] --> 4
4: [0...................................................................................................]
4: [0000000000000000000000000000100000000010000000000000000000000000000000000000001100000001100000000100] --> 5
5: [0...................................................................................................]
5: [0000000000000000000000000000000000000000000000000000000000000000000000000000011100000001010000000110] --> 6
6: [0...................................................................................................]
6: [0000000000000000000000000000000000000000000000000000000000000000000010000000010100000010010000000110] --> 7
7: [0...................................................................................................]
7: [0000000000000000000000000000000000000000000000000000000000000000000010000000010100000010010000000110] --> 8
8: [0...................................................................................................]
(jgol-peer) 🦐/c/j/peer (main) [SIGSEGV]> sudo8: [0000000000000000000000000000000000000000000000000000000000000000000010000000010100000010010000000110] --> 9test_unit.py 100 100
(jgol-peer) 🦐/c/j/peer (main) [SIGSEGV]> sudo ki9: [0...................................................................................................]
(jgol-peer) 🦐/c/j/peer (main) [SIGSEGV]> sudo killa9: [0000000000000000000000000000000000000000000000000000000000000000000010000000010100000010010000000110] --> 10
(jgol-peer) 🦐/c/j/peer (main) [SIGSEGV]> sudo killall 10: [0...................................................................................................]
(jgol-peer) 🦐/c/j/peer (main) [SIGSEGV]> sudo killall -10: [0000000000000000000000000000000000000000000000000000000000000000000010000000010100000010010000000110] --> 11
(jgol-peer) 🦐/c/j/peer (main) [SIGSEGV]> sudo killall -9 py11: [0...................................................................................................]
(jgol-peer) 🦐/c/j/peer (main) [SIGSEGV]> sudo killall -9 python
(jgol-peer) 🦐/c/j/peer (main)>

P.S. I'm sorry I don't have a compact reproducer at this point

CPython versions tested on:

3.15

Operating systems tested on:

macOS

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.15new features, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytopic-profilingtype-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