================
@@ -864,11 +864,18 @@ INTERCEPTOR(void *, pvalloc, size_t size) {
 #define RTSAN_MAYBE_INTERCEPT_PVALLOC
 #endif
 
+#if !SANITIZER_FREEBSD
+// enabling this interception on freebsd leads to infinite recursion
+// on pthread lib initialization
----------------
davidtrevelyan wrote:

I see - thanks. Does the problem go away if you put the `pthread_once` 
invocation into a disabled scope?

```cpp
static __rtsan::Context &GetContextForThisThreadImpl() {
  // ...
  {
    __rtsan::ScopedDisabler d;
    pthread_once(&key_once, MakThreadLocalContextKey);
  }
  // ...
```

I don't think this would be too unreasonable if the FreeBSD implementation of 
`pthread_once` allocates. I guess we can study the FreeBSD 
[source](https://github.com/freebsd/freebsd-src/blob/f8f5b658bc76cd539951fb8ac712d9acf71763ca/lib/libthr/thread/thr_once.c#L35)
 to find more details.

What do you think @cjappl? Disabling inside `GetContextForThisThread` make me a 
little uneasy as I haven't been able to consider all the implications. But I 
think it's potentially worth considering if it means we get to keep all 
interceptors on FreeBSD...

https://github.com/llvm/llvm-project/pull/125389
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to