Ray's Knowledge Base
Unlock

DFTracer 2.2.0 preload crashes multithreaded programs in its stdio wrappers; trace them with one worker thread

PitfallVerified 21 Oct 2026Holds dftracer: 2.2.0.post8.dev0
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

A program run with LD_PRELOAD=libdftracer_preload.so and DFTRACER_INIT=PRELOAD dies with SIGSEGV (rc 139) or "*** stack smashing detected ***" (rc 134) at random; the same command passes on the next try. gdb frames: brahma::STDIODFTracer::fopen <- fopen_wrapper, or __strlen_avx2 <- dftracer::Metadata::get_hash <- Metadata::insert_or_assign <- brahma::STDIODFTracer::fclose <- fclose_wrapper.

Cause#

A thread race in DFTracer's stdio (FILE*) tracking when many threads call fopen/fclose at once. DFTracer is fine for multi-process programs.

Fix#

Run the traced program with one worker thread (for dftracer-utils tools: --executor-threads 1 and DFTRACER_UTILS_THREADS=1; scale_ladder.py --dftracer LIB --threads 1). Keep DFTRACER_INC_METADATA=1 and stdio tracing on; turning them off loses the information and does not stop every crash.

Evidence#

2026-10-21 Corona, dftracer 2.2.0.post8.dev0, dftracer_pgzip and dftracer_event_count on a 14k-file trace set, 3 tries each: 96 threads crash; INC_METADATA=0 crashed 5 of 6; DISABLE_STDIO=1 crashed 1 of 6; 4 threads crashed 1 of 6; 1 thread passed 6 of 6 with full tracing.