Repository navigation
Description
What happens
The TSAN concurrency soak aborts, at a rate near one run in four. The process
dies with SIGABRT, and no data race is reported.
Signals delivery fails constantly at GC nixidae/nixidae#30
Signals delivery fails constantly
Fatal Python error: Aborted
libc.so.6, at abort
libtsan.so, at __interceptor_abort
libgc.so.1, at GC_generic_malloc_many
libnixexpr.so.2.34.8, at nix::EvalState::allocValue
Boehm suspends every other thread with a signal before it collects. TSAN
intercepts signal delivery. When Boehm cannot stop the world it gives up and
calls abort, and TSAN's own abort interceptor is the frame above it.
nix::EvalState::allocValue is the allocation that triggers the collection,
so the soak's evaluator work is what reaches it.
Measurements
Every run below is seed 2, local,daemon, on the same machine.
| build | ceiling | runs | aborts |
|---|---|---|---|
| this branch | vomit (the default) |
7 | 2 |
| this branch | error |
8 | 2 |
| before the verbosity fix | vomit |
8 | 0 |
The ceiling does not matter. NANOPYNIX_LOG_CEILING=error restores the
gate that Nix had before #92 pinned the global, so a debug() site drops its
message without formatting it. That removes the extra allocation and the
extra time per log site, which was the one mechanism by which #92 could reach
a timing-sensitive failure. The abort rate does not move.
The last row is not evidence of a difference. At a rate of 4 in 15, the
probability of 0 aborts in 8 runs is 0.73^8, near 0.08. The two builds also
have different roster membership, and this failure is sensitive to allocation
pressure. So the row neither shows that #92 causes the abort nor shows that
it does not.
What is clear: the soak is the workload that reaches this. The TSAN job on
develop has no soak, and it passes.
Why this is upstream, and what is left to decide
Boehm and TSAN disagree about who owns signal delivery. Neither Nix nor
nanopynix chooses that. The options that this repository does control:
- Give the soak job a retry budget. The failure is not a finding, so a
run that aborts says nothing about the code. A retry keeps the job honest
about races while it tolerates a collector that cannot stop the world. - Lower the allocation pressure of the soak. Fewer lanes, or fewer
evaluator-heavy tests in one lane, means fewer collections. - Ask Boehm to use a different signal.
GC_set_suspend_signaland
GC_set_thr_restart_signalexist. Whether a signal outside TSAN's
interception set works is untested.
Option 1 is the smallest, and it does not hide a race: TSAN reports a race
before the process reaches a collection, and a race already fails the job on
its own.
Acceptance criteria
- The soak job does not go red on an abort that reports no race.
- A run that does report a race still fails the job.
- The log says plainly that an abort happened, and how many attempts ran, so
a reader can see the rate rather than guess it.
Refs #92
Activity
test(tsan): keep the soak honest about what it can report
test(tsan): keep the soak honest about what it can report
test(tsan): keep the soak honest about what it can report
test(tsan): keep the soak honest about what it can report
test(tsan): keep the soak honest about what it can report
test(tsan): keep the soak honest about what it can report
Lillecarl commentedon Aug 4, 2026
Root cause found, and Boehm already carries the correction
Boehm knows about this failure, and it has a branch for it.
include/private/gc_priv.h:That is the abort, described by the people who wrote the collector. Without
the macro the suspend signal is
SIGPWR, which is asynchronous, and theTSAN runtime holds it. Boehm then gives up and calls
abort.The macro does not define itself in this build.
gcconfig.hsets itfrom
__has_feature(thread_sanitizer), and the branch for a compiler withno
__has_featurereads__SANITIZE_ADDRESS__only -- there is no__SANITIZE_THREAD__beside it. This build uses GCC 15.3.0. Sonix/sanitizer.nixinstrumented boehmgc without telling boehmgc whatinstruments it, and the signal stayed the wrong one.
sanitizeBoehmGCnow passes-DTHREAD_SANITIZER, for the TSAN variantalone. The UBSAN variant also builds a collector, and
SIGSYSthere wouldchange what that job exercises for no reason.
This closes the question the issue asked
The issue text said: "Ask Boehm to use a different signal ... Whether a
signal outside TSAN's interception set works is untested." It is not
untested by Boehm, and
SIGSYSis the answer they shipped.What the earlier answers were, and why they are not enough
GC_INITIAL_HEAP_SIZE=2 GiB. A collection that never happens cannotfail to stop the world, so a bigger initial heap lowers the rate. It took
three targeted TSAN jobs green, and then
test-tsan-nix_2_34abortedagain on the next full matrix run. It lowers a probability, and it
corrects nothing. Removed.
one signature -- status 134 together with
Signals delivery fails-- anda race or any other non-zero status still fails the job. Keep it as the
guard that says whether the signal fix holds, rather than deleting the
evidence.
Lillecarl commentedon Aug 4, 2026
Correction: the comment above is wrong, and the build already does this
I wrote that
gcconfig.hcannot detect ThreadSanitizer on GCC, and that-DTHREAD_SANITIZERwas therefore the missing correction. Both claims arefalse. GCC 15 supports
__has_feature, and it reportsthread_sanitizerunder
-fsanitize=thread:gcconfig.h:3325-3341guards the whole block ondefined(__has_feature)alone, so the macro is set. Against the real headers of the boehmgc that
this build uses:
And the selection block of
gc_priv.h:3033-3048, replicated against thosesame headers, takes the
SIGSYSbranch:So the collector this job links already suspends with
SIGSYS, and itaborts anyway. The
-DTHREAD_SANITIZERflag I added changes nopreprocessor state, and it is withdrawn. The measurement I quoted for it
never ran: I cancelled the job once the probes above answered the question.
GC_INITIAL_HEAP_SIZE=2147483648is back in the soak step, described aswhat it is -- a way to collect less often, which lowers the rate and
corrects nothing.
What this rules out, and where to look next
SIGPWRversusSIGSYSis not the cause. The abort comes fromresend_lost_signalsinpthread_stop_world.c:490: it resends the suspendsignal every 100 ms, and gives up after 150 tries with no progress. Fifteen
seconds of a thread that never acknowledges a synchronous signal is not a
lost signal. It is a thread that does not reach the handler.
Two things to check before anything else:
GC_COND_LOG_PRINTFalready printsResent %d signals after timeout, retry: %don each pass, soGC_PRINT_STATS=1names how many threads are outstanding for fifteenseconds before the abort.
gc_priv.hblamespthread_mutex_lock, andGC_usleep(
pthread_stop_world.c:41) already spins withsched_yieldunderTHREAD_SANITIZERto work around "a rare hang in usleep() trying toacquire TSan Lock". A thread that holds a TSan internal lock and cannot
run a signal handler fits every symptom, and no signal number changes it.
GC_RETRY_SIGNALS=0is not a workaround. It removes the retry loop, so theabort becomes an unbounded wait in
suspend_restart_barrier.test(tsan): keep the soak honest about what it can report
test(tsan): keep the soak honest about what it can report
Lillecarl commentedon Aug 4, 2026
This abort, #82 and #101 are one condition at one call site
Boehm's stop-the-world signal path has three ways to end when the thread it
wants to suspend is not there, and this repository has now seen all three:
pthread_kill failed at suspend: errcode= 22GC_suspend_all,raise_signalreturnsEINVALpthread_killGC_suspend_all, glibc reads a thread descriptor that is goneSignals delivery fails constantly at GC #Nresend_lost_signals,pthread_stop_world.c:491, after 150 retriesThe third row is new evidence and it is not from TSAN. The 48-second
reproducer on #82 was run against a collector built with
--enable-gc-assertions, four times. Three ended in SIGSEGV and the fourthaborted, and
addr2lineon the frames of that abort gives:So the same selection, on the same machine, with no sanitizer, produces this
issue's abort and #82's fault interchangeably. A thread that never answers is
a thread that resends 150 times and gives up; a thread whose descriptor has
been reclaimed is a fault in the
pthread_killitself. Which one lands istiming.
What that changes
TSAN is not required, and TSAN is not the cause. This issue's measurements
were all under TSAN, and the conclusion drawn was that TSAN's signal
interception was the mechanism. The plain dev shell reaches the same abort.
The remaining question is the one #82 now carries: which thread is in
GC_threadsthat should not be. A registration audit over one crashing runpairs 17 enters with 16 exits plus the live one, and never reports
GC_DUPLICATE, so nanopynix's own hooks are balanced.The assertion build is worth keeping in mind for whoever picks this up: it
reproduces at the same rate as a plain build, so
GC_ASSERTIONSfires onnothing here. Boehm's own invariants hold right up to the signal.
fix(bindings): start the collector at import, on a thread that never …
Lillecarl commentedon Aug 4, 2026
Same cause as #82: Boehm signalled a thread that had exited
GC_thr_initgives bdwgc's one staticfirst_threadentry to whicheverthread reaches
GC_INIT(), marks itDETACHED | MAIN_THREAD, and neverremoves it.
Session.openreached that call on anix-storeexecutorthread, which exits when the session closes.
GC_suspend_allthen signals adead thread on every later collection.
Three outcomes of that one signal, and each has its own issue: an
EINVALreturn (#72), a fault inside
pthread_kill(#53), and a lost signal thatmakes
resend_lost_signalsabort after 150 tries (#69).nix::initGCnow runs while the extension module imports, so the entry namesthe process main thread. #82 carries the core dump, the bdwgc reasoning, and
the measurement.
fix(bindings): own the collector's thread in C++, and start it lazily
Lillecarl commentedon Aug 5, 2026
All three acceptance criteria are met, and the mechanism that meets them is
option 1.
ci/workflows/lib.nix:477-490retries an attempt that exits 134with 10BC8
Signals delivery fails, counts it, and fails the job only when thecount passes
ABORT_BUDGET:if [ "$aborts" -gt "$ABORT_BUDGET" ], and nothing else fails on 134.ThreadSanitizer: data racegrep runs first, setsrace_found=1, andbreaks out to
exit 1. It reads$RUNLOGand not the whole log, so anearlier attempt cannot answer for this one.
=== TSAN soak summary: N tolerated collector abort(s) of a budget of 5 ===,plus the Boehm resend log of each aborted attempt.
The budget is no longer being spent
Every
test-tsan-*job since99f74d82("register the thread that builds anevaluator with Boehm") reports zero aborts. Eighteen jobs, six runs,
three Nix versions, and each job runs five seeds against the local and the
daemon backends:
The four jobs that are red in that table failed on the
gmtimerace (#90) andon the soak verbosity defect (#91). Neither reached a collector abort.
That rate is what #101 predicted. The abort was not the upstream disagreement
between Boehm and TSAN that this issue opens with. It was one bug with #82 and
#101:
GC_INITran on a store pool thread that later exited, so the collectorsignalled a
pthread_tthat glibc had handed on.Closing. The retry budget stays, and #122 asks whether it should now be zero.
ci(tsan): let one collector abort fail the soak, now that none happen
fix(nanopynix): give the evaluator a collector, and fork a contract p…
test(tsan): keep the soak honest about what it can report
fix(bindings): start the collector at import, on a thread that never …
fix(bindings): own the collector's thread in C++, and start it lazily
ci(tsan): let one collector abort fail the soak, now that none happen
fix(nanopynix): give the evaluator a collector, and fork a contract p…