samply on macOS cannot profile through /bin/bash, and --iteration-count shares one stdin
Symptom#
samply record --iteration-count 25 -- /path/run.sh ... fails with Profiling failed: Could not obtain the root task. when run.sh is a bash script. Running the binary directly with --iteration-count N ... < input.json works, but only the first run reads the input; the others see EOF and profile an error path.
Cause#
macOS system binaries (/bin/bash, system python) block DYLD_INSERT_LIBRARIES, which samply needs. And all iterations share the same stdin file descriptor.
Fix#
Run the binary itself, one recording per run, with stdin redirected each time, and sum the profiles afterwards:
for; do
done
--unstable-presymbolicate writes x_$i.json.syms.json next to each profile, so a script can map frameTable.address to symbols without the profiler UI. Build with symbols: CARGO_PROFILE_RELEASE_STRIP=none CARGO_PROFILE_RELEASE_DEBUG=line-tables-only.
Evidence#
Profiled rvow hook calls on 2026-10-22: the bash wrapper failed, the per-run loop gave 20 profiles for each hook kind.
Also found by searching
- Profiling failed: Could not obtain the root task.
- samply profile of a short process that reads stdin
- samply --iteration-count gives wrong profile for a hook