You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Metal: a run that runs out of heap sometimes faults or hangs instead of printing the out-of-memory error #1300
cd bench/runtime/tree-radix # same with tree-bitonic
bend main.bend -o main.c
cc -std=c11 -O3 -DBEND_METAL=1 -x objective-c -fobjc-arc main.c -lpthread -framework Metal -framework Foundation -o cell
./cell --gpu-build
for i in $(seq 200); do ./cell --gpu 512MB; done
--gpu 512MB is too small for either bench, so every run should end in the out-of-memory error.
What happened
Most runs print the error, but a few fault or hang instead. Over 386 runs of main's build (193 per bench):
outcome
tree-radix
tree-bitonic
bend: out of memory: run again with a bigger span, as in --gpu 8GB
So after a lane posts ERR_HEAP, something still runs into a bad address or a wait that never ends. The error flag heap_free checks (#1143) narrows this but doesn't close it: guarding only the sink page instead of that check went bad in 19 of 60 runs.
The file
bench/runtime/tree-radix/main.bend and bench/runtime/tree-bitonic/main.bend, unchanged.
Closing as a duplicate of #1924, where we're tracking this.
The faults and the hangs here both come from the window #1924 describes. After heap_alloc_miss posts ERR_HEAP and returns HEAP_OFF, a lane reads the error word only every 4096 steps, and until then it keeps stepping on nodes that other failing lanes overwrite.
To check, I ran this issue's loop (--gpu 512MB) 500 times per bench on an M4 Pro. One build was 2.0.35 (a950fd68) as is. The other was the same emitted C with one change: err_spun polls the error word on every step instead of every 4096.
build
tree-radix
tree-bitonic
2.0.35
32 OOM, 390 GPU Hang Error, 39 hangs (killed at 20 s), 25 GPU Address Fault, 6 Discarded, 5 memory fault, 3 frontier drained without a result
498 OOM, 1 hang, 1 GPU Address Fault
2.0.35, poll every step
500 OOM
500 OOM
Closing the window removes every bad outcome, hangs included, so the fix belongs to #1924.
On main (05c0dbae), the same loop printed the out-of-memory error in 1000 of 1000 runs per bench. err_spun still polls every 4096 steps there, so the window is still open and something since 2.0.35 only makes it rarer.
Activity
Lorenzobattistela commentedon Nov 5, 2026
Closing as a duplicate of #1924, where we're tracking this.
The faults and the hangs here both come from the window #1924 describes. After
heap_alloc_misspostsERR_HEAPand returnsHEAP_OFF, a lane reads the error word only every 4096 steps, and until then it keeps stepping on nodes that other failing lanes overwrite.To check, I ran this issue's loop (
--gpu 512MB) 500 times per bench on an M4 Pro. One build was 2.0.35 (a950fd68) as is. The other was the same emitted C with one change:err_spunpolls the error word on every step instead of every 4096.GPU Hang Error, 39 hangs (killed at 20 s), 25GPU Address Fault, 6Discarded, 5memory fault, 3frontier drained without a resultGPU Address FaultClosing the window removes every bad outcome, hangs included, so the fix belongs to #1924.
On main (
05c0dbae), the same loop printed the out-of-memory error in 1000 of 1000 runs per bench.err_spunstill polls every 4096 steps there, so the window is still open and something since 2.0.35 only makes it rarer.