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

Kamil Rytarowski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 3 14:28:03 PDT 2017


krytarowski created this revision.
krytarowski added a project: Sanitizers.
Herald added a subscriber: kubamracek.

The NetBSD specific implementation of cxa_atexit() does not
preserve the 2nd argument if dso is equal to NULL.

Changes:

- Split paths of handling intercepted __cxa_atexit() and atexit(3). This affects all supported Operating Systems.
- Add a local stack-like structure to hold the __cxa_atexit() context. atexit(3) is documented in the C standard as calling callback from the earliest to the oldest entry. This path also fixes potential ABI problem of passing an argument to a function from the atexit(3) callback mechanism.
- Introduce new internal allocator: InternalReallocArr() that has been modeled after NetBSD's reallocarr(3) extension to libc. This function is handy to resize/free arrays.

With the above changes and few local patches, TSan/NetBSD can
bootstrap into operation.

Sponsored by <The NetBSD Foundation>


Repository:
  rL LLVM

https://reviews.llvm.org/D39619

Files:
  lib/sanitizer_common/sanitizer_allocator.cc
  lib/sanitizer_common/sanitizer_allocator_internal.h
  lib/tsan/rtl/tsan_interceptors.cc

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39619.121552.patch
Type: text/x-patch
Size: 3472 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171103/65e39b79/attachment.bin>


More information about the llvm-commits mailing list