Skip to content

Commit 5b6911c

Browse files
vitalybukaAlexisPerry
authored andcommitted
[sanitizer] Rename DEFINE_REAL_PTHREAD_FUNCTIONS (llvm#96527)
We use REAL() calls in interceptors, but DEFINE_REAL_PTHREAD_FUNCTIONS has nothing to do with them and only used for internal maintenance threads. This is done to avoid confusion like in llvm#96456.
1 parent 8fb7e9d commit 5b6911c

File tree

9 files changed

+29
-29
lines changed

9 files changed

+29
-29
lines changed

compiler-rt/lib/asan/asan_interceptors.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ INTERCEPTOR(int, pthread_timedjoin_np, void *thread, void **ret,
333333
}
334334
# endif
335335

336-
DEFINE_REAL_PTHREAD_FUNCTIONS
336+
DEFINE_INTERNAL_PTHREAD_FUNCTIONS
337337
#endif // ASAN_INTERCEPT_PTHREAD_CREATE
338338

339339
#if ASAN_INTERCEPT_SWAPCONTEXT

compiler-rt/lib/hwasan/hwasan_interceptors.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ INTERCEPTOR(int, pthread_timedjoin_np, void *thread, void **ret,
334334
}
335335
# endif
336336

337-
DEFINE_REAL_PTHREAD_FUNCTIONS
337+
DEFINE_INTERNAL_PTHREAD_FUNCTIONS
338338

339339
DEFINE_REAL(int, vfork,)
340340
DECLARE_EXTERN_INTERCEPTOR_AND_WRAPPER(int, vfork,)

compiler-rt/lib/lsan/lsan_interceptors.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ INTERCEPTOR(int, pthread_timedjoin_np, void *thread, void **ret,
525525
# define LSAN_MAYBE_INTERCEPT_TIMEDJOIN
526526
# endif // SANITIZER_INTERCEPT_TIMEDJOIN
527527

528-
DEFINE_REAL_PTHREAD_FUNCTIONS
528+
DEFINE_INTERNAL_PTHREAD_FUNCTIONS
529529

530530
INTERCEPTOR(void, _exit, int status) {
531531
if (status == 0 && HasReportedLeaks()) status = common_flags()->exitcode;

compiler-rt/lib/memprof/memprof_interceptors.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ INTERCEPTOR(int, pthread_join, void *t, void **arg) {
166166
return REAL(pthread_join)(t, arg);
167167
}
168168

169-
DEFINE_REAL_PTHREAD_FUNCTIONS
169+
DEFINE_INTERNAL_PTHREAD_FUNCTIONS
170170

171171
INTERCEPTOR(char *, index, const char *string, int c)
172172
ALIAS(WRAP(strchr));

compiler-rt/lib/msan/msan_interceptors.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ INTERCEPTOR(int, pthread_timedjoin_np, void *thread, void **retval,
12261226
}
12271227
#endif
12281228

1229-
DEFINE_REAL_PTHREAD_FUNCTIONS
1229+
DEFINE_INTERNAL_PTHREAD_FUNCTIONS
12301230

12311231
extern char *tzname[2];
12321232

compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ void MaybeStartBackgroudThread() {
8787
if (!common_flags()->hard_rss_limit_mb &&
8888
!common_flags()->soft_rss_limit_mb &&
8989
!common_flags()->heap_profile) return;
90-
if (!&real_pthread_create) {
91-
VPrintf(1, "%s: real_pthread_create undefined\n", SanitizerToolName);
90+
if (!&internal_pthread_create) {
91+
VPrintf(1, "%s: internal_pthread_create undefined\n", SanitizerToolName);
9292
return; // Can't spawn the thread anyway.
9393
}
9494

compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,18 +1845,18 @@ HandleSignalMode GetHandleSignalMode(int signum) {
18451845

18461846
# if !SANITIZER_GO
18471847
void *internal_start_thread(void *(*func)(void *arg), void *arg) {
1848-
if (&real_pthread_create == 0)
1848+
if (&internal_pthread_create == 0)
18491849
return nullptr;
18501850
// Start the thread with signals blocked, otherwise it can steal user signals.
18511851
ScopedBlockSignals block(nullptr);
18521852
void *th;
1853-
real_pthread_create(&th, nullptr, func, arg);
1853+
internal_pthread_create(&th, nullptr, func, arg);
18541854
return th;
18551855
}
18561856

18571857
void internal_join_thread(void *th) {
1858-
if (&real_pthread_join)
1859-
real_pthread_join(th, nullptr);
1858+
if (&internal_pthread_join)
1859+
internal_pthread_join(th, nullptr);
18601860
}
18611861
# else
18621862
void *internal_start_thread(void *(*func)(void *), void *arg) { return 0; }

compiler-rt/lib/sanitizer_common/sanitizer_posix.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,21 @@ int internal_sysctlbyname(const char *sname, void *oldp, uptr *oldlenp,
7474
// These functions call appropriate pthread_ functions directly, bypassing
7575
// the interceptor. They are weak and may not be present in some tools.
7676
SANITIZER_WEAK_ATTRIBUTE
77-
int real_pthread_create(void *th, void *attr, void *(*callback)(void *),
78-
void *param);
77+
int internal_pthread_create(void *th, void *attr, void *(*callback)(void *),
78+
void *param);
7979
SANITIZER_WEAK_ATTRIBUTE
80-
int real_pthread_join(void *th, void **ret);
81-
82-
#define DEFINE_REAL_PTHREAD_FUNCTIONS \
83-
namespace __sanitizer { \
84-
int real_pthread_create(void *th, void *attr, void *(*callback)(void *), \
85-
void *param) { \
86-
return REAL(pthread_create)(th, attr, callback, param); \
87-
} \
88-
int real_pthread_join(void *th, void **ret) { \
89-
return REAL(pthread_join(th, ret)); \
90-
} \
91-
} // namespace __sanitizer
80+
int internal_pthread_join(void *th, void **ret);
81+
82+
# define DEFINE_INTERNAL_PTHREAD_FUNCTIONS \
83+
namespace __sanitizer { \
84+
int internal_pthread_create(void *th, void *attr, \
85+
void *(*callback)(void *), void *param) { \
86+
return REAL(pthread_create)(th, attr, callback, param); \
87+
} \
88+
int internal_pthread_join(void *th, void **ret) { \
89+
return REAL(pthread_join(th, ret)); \
90+
} \
91+
} // namespace __sanitizer
9292

9393
int internal_pthread_attr_getstack(void *attr, void **addr, uptr *size);
9494

compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,14 +1088,14 @@ TSAN_INTERCEPTOR(int, pthread_join, void *th, void **ret) {
10881088
return res;
10891089
}
10901090

1091-
// DEFINE_REAL_PTHREAD_FUNCTIONS
1091+
// DEFINE_INTERNAL_PTHREAD_FUNCTIONS
10921092
namespace __sanitizer {
1093-
int real_pthread_create(void *th, void *attr, void *(*callback)(void *),
1094-
void *param) {
1093+
int internal_pthread_create(void *th, void *attr, void *(*callback)(void *),
1094+
void *param) {
10951095
ScopedIgnoreInterceptors ignore;
10961096
return REAL(pthread_create)(th, attr, callback, param);
10971097
}
1098-
int real_pthread_join(void *th, void **ret) {
1098+
int internal_pthread_join(void *th, void **ret) {
10991099
ScopedIgnoreInterceptors ignore;
11001100
return REAL(pthread_join(th, ret));
11011101
}

0 commit comments

Comments
 (0)