Bug 215798 - clang: please Include thread sanitizer (and all other available sanitizers)
Summary: clang: please Include thread sanitizer (and all other available sanitizers)
Status: Closed Overcome By Events
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-toolchain (Nobody)
URL:
Keywords:
: 215975 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-01-05 15:04 UTC by german.mb
Modified: 2024-04-14 17:32 UTC (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description german.mb 2017-01-05 15:04:29 UTC
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
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2017-01-06 22:49:26 UTC
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. :-)
Comment 2 Dimitry Andric freebsd_committer freebsd_triage 2017-01-11 18:33:05 UTC
*** Bug 215975 has been marked as a duplicate of this bug. ***
Comment 3 Sean McBride 2019-02-13 20:56:04 UTC
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?
Comment 4 Dimitry Andric freebsd_committer freebsd_triage 2019-02-13 20:59:47 UTC
(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.
Comment 5 Christoph Moench-Tegeder freebsd_committer freebsd_triage 2019-02-15 12:16:54 UTC
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.
Comment 6 Sean McBride 2019-02-21 22:54:20 UTC
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."
Comment 7 Dimitry Andric freebsd_committer freebsd_triage 2024-04-14 17:32:04 UTC
Very old bug. We now include most sanitizers for the architectures where upstream supports them.