Thread sanitizers where created to build safer/more secure code; it is my opinion all available clang thread sanitizers should be readily usable from the base system. In particular, I'd ve very interested in having thread sanitizer included as part of the base system, currently, when I try to compile using it, it gives me this error (FreeBSD 11): /usr/bin/ld: /usr/bin/../lib/clang/3.8.0/lib/freebsd/libclang_rt.tsan-x86_64.a: No such file: No such file or directory
The problem is that the thread sanitizer currently does not work on FreeBSD. This has to do with the way thread sanitizer attempts to initialize very early during program startup, and it conflicts with jemalloc's early initialization. This leads to an endless recursion, and a stack overflow. For thread sanitizer to work properly, it looks like we will need some sort of hook in libc, which can be used to initialize thread sanitizer before jemalloc is initialized. I have limited time, so I have not yet worked on this. Patches are welcome. :-)
*** Bug 215975 has been marked as a duplicate of this bug. ***
The clang docs say TSan works on FreeBSD: https://clang.llvm.org/docs/ThreadSanitizer.html yet this bug is open. Does FreeBSD support TSan or not?
(In reply to Sean McBride from comment #3) > The clang docs say TSan works on FreeBSD: > https://clang.llvm.org/docs/ThreadSanitizer.html > > yet this bug is open. > > Does FreeBSD support TSan or not? As far as I know, TSan is still broken. At least, with the most recent 8.0 release, it gets into an endless loop, and crashes due to a stack overflow on initialization.
At least for trivial examples (like the one in the clang documentation), TSan from devel/llvm60 and devel/llvm70 does work as advertised on amd64. And then, the documentation states "Support for 32-bit platforms is problematic and is not planned.", so that's about it for i386. And then, my 12.0-STABLE machine does have /usr/lib/clang/6.0.1/lib/freebsd/libclang_rt.tsan-x86_64.a /usr/lib/clang/6.0.1/lib/freebsd/libclang_rt.tsan_cxx-x86_64.a and quite a few more sanitizers.
And just today on the clang mailing list: http://lists.llvm.org/pipermail/cfe-dev/2019-February/061374.html "I think the release is looking pretty good, but there is one blocker that's worrying me: https://llvm.org/PR40761 >From what I understand, ASan et al. used to work on FreeBSD but don't anymore, and there's nobody working on it. Is there someone who has access to a FreeBSD machine that could help investigate this? Just getting it bisected would be super helpful."
Very old bug. We now include most sanitizers for the architectures where upstream supports them.