Repository navigation
profiling SEGV with --mode=gil with freethreading #140739
Copy link
Copy link
Closed
Labels
3.15bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-profilingtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Description
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.15bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-profilingtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Activity
[-]profiling SEGV with --model=gil with freethreading[/-][+]profiling SEGV with --mode=gil with freethreading[/+]pablogsal commentedon Dec 26, 2025
I cannot repro anymore with the current main. I used this script:
pablogsal commentedon Dec 26, 2025
Let's reopen if you see it again
dimaqq commentedon Dec 26, 2025
I can't repro with your code either.
Let me dig up the original workload, and I'll make a separate repo for the reporoducer.
dimaqq commentedon Dec 26, 2025
Hmmm... this is getting more interesting: I get a crash in my existing venv, but it's harder to get a crash, and I'm getting potentially different crash with fresh versions of dependencies:
That's newer
Python 3.15.0a2 free-threading build (main, Dec 5 2025, 20:59:15) [Clang 21.1.4 ] on darwinThe shell shows that last command died SIGBUS, also the test is not supposed to exit so quickly, should have continued until
--> 100rounds.Here are all the dependencies used:
I think that only PyYAML is a compiled dep, and everything else is pure Python.
I'll try to make a smaller MRE.
pablogsal commentedon Dec 26, 2025
Thanks! It will help immensely if you could give us a trace with lldb. Also if you could test with main that would help too. 3.15.0a2 is quite outdated at this point
pablogsal commentedon Dec 26, 2025
Can you paste here the original workload even if is huge?
pablogsal commentedon Dec 26, 2025
Ah I think I found the problem
dimaqq commentedon Dec 26, 2025
MRE https://github.com/dimaqq/repro-cpython-140739
pablogsal commentedon Dec 26, 2025
Thanks a lot! Yeah, this indeed confirms my theory. Will work on a fix! This was very useful thanks for all the help
dimaqq commentedon Dec 26, 2025
No worries, thank you for you hard work during the holiday season ❤️
pythongh-140739: Fix crashes from corrupted remote memory
gh-140739: Fix crashes from corrupted remote memory (#143190)
pablogsal commentedon Dec 26, 2025
@dimaqq can you check again with the current main? :)
pythongh-140739: Fix missing exception on allocation failure in Binar…
gh-140739: Fix missing exception on allocation failure in BinaryWriter (
dimaqq commentedon Dec 29, 2025
I'll have to get back to this in 2026.
(couldn't build the main branch, PEBKAC; and off to holidays)
pythongh-140739: Fix crashes from corrupted remote memory (python#143190
pythongh-140739: Fix missing exception on allocation failure in Binar…