| Summary: | ThreadSanitizer (-fsanitize=thread) segfault before reaching main() | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Build System, Metadata & Runtime] OE-Core | Reporter: | Tony Battersby <tonyb> | ||||
| Component: | devtools / tool chain | Assignee: | Randy MacLeod <randy.macleod> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | Medium+ | CC: | meta.mr.watcher, meta.watcher, raj.khem, randy.macleod, sundeep.kokkonda | ||||
| Version: | 3.4.1 | ||||||
| Target Milestone: | 4.0 M4 | ||||||
| Hardware: | x86 | ||||||
| OS: | x86_64 | ||||||
| Whiteboard: | |||||||
| OS type for building Yocto: | --- | Type of Regression: | --- | ||||
| Verified: | Documentation change: | No (bug/feature does not impact docs) | |||||
| Attachments: |
|
||||||
We should add a test case. The issue is in the 'GetAltStackSize' function from below file. ..\libsanitizer\sanitizer_common\sanitizer_posix_libcdep.cpp This function calls recursively and causing the SIGSEGV fault. The fix for this issue is available in below patch. https://gcc.gnu.org/git/?p=gcc.git;a=blobdiff;f=libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp;h=ddf6844bed13efeb3f7f87aee664b6b96682a8f6;hp=d1d8e509c4dbaa2cb1a0d020959765c20fa7a895;hb=90e46074e6b3561ae7d8ebd205127f286cc0c6b6;hpb=8bf5b49ebd2176b8c535147377381dd07fbdd643 This change is not yet included in the current released version of GCC. Updating to next GCC version (GCC-11.3, yet to be released) will fix the issue. The next GCC release is not near so the patch is backported and submitted to upstream. Below are the details. https://lists.openembedded.org/g/openembedded-core/message/163047 |
Created attachment 4847 [details] Trivial test program that segfaults before reaching main Since Yocto 3.4, any C program that is compiled with -fsanitize=thread segfaults in libtsan before it even gets to main(). Even the trivial program: int main(int argc, char **argv){return 0;} Kernel dmesg output: tsan-test[10113]: segfault at 600000000008 ip 00007f386a5bbb7f sp 00007fffa57e2900 error 6 in libtsan.so.0.0.0[7f386a543000+b4000] Code: f7 c2 ff 1f 00 00 0f 84 7f 00 00 00 48 c1 e8 32 25 ff 1f 00 00 48 69 c0 00 00 13 01 48 8d 14 d0 48 b8 00 00 00 00 00 60 00 00 <48> c7 04 02 00 00 00 00 8b 43 1c 85 c0 75 3d 8b 93 70 02 00 00 48 I have attached a recipe with the test program to reproduce the problem. ThreadSanitizer worked in Yocto 3.3.3 with gcc 10.2. It broke when we upgraded to Yocto 3.4.1 with gcc 11.2. I also tested poky master and master-next on 2021-12-30; they also fail. Note that AddressSanitizer and UndefinedBehaviorSanitizer seem to be working OK so far in Yocto 3.4.1. It is just ThreadSanitizer that is not working.