Correct NetBSD support in pthread_once(3)/TSan
authorKamil Rytarowski <n54@gmx.com>
Tue, 21 Nov 2017 09:36:07 +0000 (09:36 +0000)
committerKamil Rytarowski <n54@gmx.com>
Tue, 21 Nov 2017 09:36:07 +0000 (09:36 +0000)
commitd7c85137aa392e8879dd7d37f3bb951def683e08
tree633f5a159d50a0b55107c20d60d8875ff1152fea
parent7ca5e5873616c56f6ce473588a303af143b553f1
Correct NetBSD support in pthread_once(3)/TSan

Summary:
The pthread_once(3)/NetBSD type is built with the following structure:

struct __pthread_once_st {
 pthread_mutex_t pto_mutex;
 int pto_done;
};

Set the pto_done position as shifted by __sanitizer::pthread_mutex_t_sz
from the beginning of the pthread_once struct.

This corrects deadlocks when the pthread_once(3) function
is used.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, dvyukov, vitalybuka

Reviewed By: dvyukov

Subscribers: llvm-commits, kubamracek, #sanitizers

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D40262

llvm-svn: 318742
compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_netbsd.cc
compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_netbsd.h
compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
compiler-rt/lib/tsan/rtl/tsan_interceptors.cc