[PATCH] D40243: Handle NetBSD specific indirection of libpthread functions

Dmitry Vyukov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 20 05:36:58 PST 2017


dvyukov added a comment.

In https://reviews.llvm.org/D40243#930139, @krytarowski wrote:

> There is an open question what to do with tests. They report results with the mangled name in stack trace, instead of the regular libpthread(3) ones.
>
>   $ ./mutex                                                                    
>   ==================
>   WARNING: ThreadSanitizer: data race (pid=13274)
>     Write of size 4 at 0x0000014f9ec0 by thread T1 (mutexes: write M76):
>       #0 Thread1(void*) /public/llvm-build/mutex.cc:36:9 (mutex+0x46e5ec)
>  
>     Previous write of size 4 at 0x0000014f9ec0 by thread T2:
>       #0 Thread2(void*) /public/llvm-build/mutex.cc:42:9 (mutex+0x46e6b7)
>  
>     Location is global 'Global' of size 4 at 0x0000014f9ec0 (mutex+0x0000014f9ec0)
>  
>     Mutex M76 (0x0000014f9ec8) created at:
>       #0 __libc_mutex_init /public/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:1137:3 (mutex+0x413ef3)
>       #1 main /public/llvm-build/mutex.cc:66:3 (mutex+0x46e796)
>  
>     Thread T1 (tid=2, running) created by main thread at:
>       #0 pthread_create /public/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:921:3 (mutex+0x412cf0)
>       #1 main /public/llvm-build/mutex.cc:71:3 (mutex+0x46e7b5)
>  
>     Thread T2 (tid=3, finished) created by main thread at:
>       #0 pthread_create /public/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:921:3 (mutex+0x412cf0)
>       #1 main /public/llvm-build/mutex.cc:72:3 (mutex+0x46e7d4)
>  
>   SUMMARY: ThreadSanitizer: data race /public/llvm-build/mutex.cc:36:9 in Thread1(void*)
>   ==================
>   ThreadSanitizer: reported 1 warnings
>
>
> `__libc_mutex_init` printed instead of `pthread_mutex_init`. This breaks tests that check for exact strings.
>
> I will implement fix for tests (demangle names or change tests) in a dedicated review.


Check out PrintStack in tsan_report.cc. We already mess with interceptor names there (e.g. with interceptors they would like as __interceptor_pthread_mutex_lock even on linux). I think it's the right place to patch function names.



================
Comment at: lib/tsan/rtl/tsan_interceptors.cc:2480
+// NetBSD uses indirection for old threading functions for historical reasons
+TSAN_INTERCEPTOR(void, __libc_cond_init, void *c, void *a) \
+  ALIAS(WRAPPER_NAME(pthread_cond_init));
----------------
Perhaps we need some helper macro so this can be spelled along the lines of:
```
NETBSD_ALIAS(cond_init);
```
I think we could declare all alias functions as taking no arguments.


Repository:
  rL LLVM

https://reviews.llvm.org/D40243





More information about the llvm-commits mailing list