[PATCH] D39619: Correct atexit(3) support in TSan/NetBSD

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 3 15:15:55 PDT 2017


vitalybuka added a comment.

thanks for splitting.
I don't have particular opinion on the patch, just some nits.
Maybe wait for @dvyukov input?



================
Comment at: lib/sanitizer_common/sanitizer_allocator.cc:196
+  naddr = InternalRealloc(oaddr, count * size, cache);
+  if (naddr == 0) return -1;
+
----------------
!naddr


================
Comment at: lib/tsan/rtl/tsan_interceptors.cc:398
+static void at_exit_wrapper() {
+  ThreadState *thr = cur_thread();
+  uptr pc = 0;
----------------
could you please move both vars closed to the use?


================
Comment at: lib/tsan/rtl/tsan_interceptors.cc:410
+
+  Acquire(thr, pc, (uptr)ctx);
+  ((void(*)())ctx->f)();
----------------
Dmitry, can this be just "Acquire(cur_thread(), 0, (uptr)ctx);" ?


================
Comment at: lib/tsan/rtl/tsan_interceptors.cc:457
+    // NetBSD does not preserve the 2nd argument if dso is equal to 0
+    // Store ctx in a local stack-like structure
+    res = REAL(__cxa_atexit)((void (*)(void *a))at_exit_wrapper, 0, 0);
----------------
maybe

```
int res = REAL(__cxa_atexit)((void (*)(void *a))at_exit_wrapper, dso ? ctx : 0, dso);
if (!dso) {
  ...
}
```


Repository:
  rL LLVM

https://reviews.llvm.org/D39619





More information about the llvm-commits mailing list