Repository navigation
feat(crash-handler): opt-in sanitizer-compat feature to fix LSan ab… - #124
Merged
Jake-Shadle merged 2 commits intoSep 25, 2026
Conversation
Contributor
Author
|
@Jake-Shadle 👋 any chance you could take a look at this one? |
…ort (EmbarkStudios#123) Linking `crash-handler` exports an unconditional `#[no_mangle] pthread_create` that interposes the process's `pthread_create`. Under a sanitizer (`-Zsanitizer=leak`/`address`/`thread`) this strong symbol shadows the sanitizer's weak `pthread_create` alias, and the interposer's `dlsym(RTLD_NEXT, ...)` resolves straight to libc — bypassing the sanitizer's create-side bookkeeping while its `pthread_join` interceptor stays active. LSan then aborts at teardown with "Joining already joined thread". Add an opt-in `sanitizer-compat` Cargo feature (off by default). When enabled, the interposer chains to the sanitizer's `__interceptor_pthread_create` (resolved via a link-time `extern_weak` reference — null when no sanitizer is linked) instead of libc, keeping the sanitizer in the loop: `pthread_create -> __interceptor_pthread_create -> libc`. The feature gates BOTH the crate-level `#![feature(linkage)]` attribute and the weak extern block, so stable builds are entirely unaffected (feature off = no nightly requirement). A `-Zsanitizer` build is already nightly-only (`-Zbuild-std`), so turning the feature on adds no new toolchain constraint. Implements the feature-gated approach outlined in EmbarkStudios#123. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Jake-Shadle
force-pushed
the
fix/issue-123-sanitizer-compat-feature
branch
from
September 25, 2026 09:00
faad449 to
89fae0d
Compare
Jake-Shadle
approved these changes
Sep 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…ort (#123)
Linking
crash-handlerexports an unconditional#[no_mangle] pthread_createthat interposes the process'spthread_create. Under a sanitizer (-Zsanitizer=leak/address/thread) this strong symbol shadows the sanitizer's weakpthread_createalias, and the interposer'sdlsym(RTLD_NEXT, ...)resolves straight to libc — bypassing the sanitizer's create-side bookkeeping while itspthread_joininterceptor stays active. LSan then aborts at teardown with "Joining already joined thread".Add an opt-in
sanitizer-compatCargo feature (off by default). When enabled, the interposer chains to the sanitizer's__interceptor_pthread_create(resolved via a link-timeextern_weakreference — null when no sanitizer is linked) instead of libc, keeping the sanitizer in the loop:pthread_create -> __interceptor_pthread_create -> libc.The feature gates BOTH the crate-level
#![feature(linkage)]attribute and the weak extern block, so stable builds are entirely unaffected (feature off = no nightly requirement). A-Zsanitizerbuild is already nightly-only (-Zbuild-std), so turning the feature on adds no new toolchain constraint.Implements the feature-gated approach outlined in #123.