Description
Encountered the same issue as reported in google/sanitizers#1713 where attempting to instrument any code with TSAN in Alpine Linux would cause a segmentation fault before main
is called.
The source of this appears to be related to the use of .preinit_array
to initialize TSAN - the musl-based dynamic linker/loader used in Alpine does not have the expected support for this section that the compile time feature checks expect based on the platform. As a result, the runtime is not initialized, causing the segmentation fault when an intercepted function is called.
I have confirmed this by experimenting with modifying LazyInitialize
in tsan_rtl.h
to remove the preprocessor conditions that exclude the implementation when .preinit_array
is expected to have already initialized the runtime. This fixes the observed issue in my testing, getting the expected TSAN output for the example racy code.
Unsure of the context of the potential cost of removing these on more common platforms - ideally the feature check would simply be more accurate, but not sure of feasibility.