[compiler-rt] 87261ca - tsan: use pthread_equal instead of direct pthread_t comparison
Dmitry Vyukov via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 15 22:51:28 PST 2021
Author: Dmitry Vyukov
Date: 2021-11-16T07:51:24+01:00
New Revision: 87261caa550d2399b0556af44f60e1482d8c4179
URL: https://github.com/llvm/llvm-project/commit/87261caa550d2399b0556af44f60e1482d8c4179
DIFF: https://github.com/llvm/llvm-project/commit/87261caa550d2399b0556af44f60e1482d8c4179.diff
LOG: tsan: use pthread_equal instead of direct pthread_t comparison
man pthread_equal:
The pthread_equal() function is necessary because thread IDs
should be considered opaque: there is no portable way for
applications to directly compare two pthread_t values.
Depends on D113916.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D113919
Added:
Modified:
compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
index 2f04cd24ee3a..25dbe487b280 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
@@ -2134,11 +2134,11 @@ TSAN_INTERCEPTOR(int, pthread_kill, void *tid, int sig) {
ThreadSignalContext *sctx = SigCtx(thr);
CHECK_NE(sctx, 0);
int prev = sctx->int_signal_send;
- if (tid == pthread_self()) {
+ bool self = pthread_equal(tid, pthread_self());
+ if (self)
sctx->int_signal_send = sig;
- }
int res = REAL(pthread_kill)(tid, sig);
- if (tid == pthread_self()) {
+ if (self) {
CHECK_EQ(sctx->int_signal_send, sig);
sctx->int_signal_send = prev;
}
More information about the llvm-commits
mailing list