Skip to content

Commit 966b518

Browse files
committed
Change internal_start_thread arguments to match pthread_create.
This avoids a CFI-unfriendly function pointer type cast in internal_start_thread.
1 parent 9d9b470 commit 966b518

File tree

7 files changed

+13
-11
lines changed

7 files changed

+13
-11
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ INLINE uptr GetPthreadDestructorIterations() {
855855
#endif
856856
}
857857

858-
void *internal_start_thread(void(*func)(void*), void *arg);
858+
void *internal_start_thread(void *(*func)(void*), void *arg);
859859
void internal_join_thread(void *th);
860860
void MaybeStartBackgroudThread();
861861

compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ SANITIZER_WEAK_ATTRIBUTE StackDepotStats *StackDepotGetStats() {
3030
return nullptr;
3131
}
3232

33-
void BackgroundThread(void *arg) {
33+
void *BackgroundThread(void *arg) {
3434
const uptr hard_rss_limit_mb = common_flags()->hard_rss_limit_mb;
3535
const uptr soft_rss_limit_mb = common_flags()->soft_rss_limit_mb;
3636
const bool heap_profile = common_flags()->heap_profile;

compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,7 +1701,7 @@ HandleSignalMode GetHandleSignalMode(int signum) {
17011701
}
17021702

17031703
#if !SANITIZER_GO
1704-
void *internal_start_thread(void(*func)(void *arg), void *arg) {
1704+
void *internal_start_thread(void *(*func)(void *arg), void *arg) {
17051705
// Start the thread with signals blocked, otherwise it can steal user signals.
17061706
__sanitizer_sigset_t set, old;
17071707
internal_sigfillset(&set);
@@ -1712,7 +1712,7 @@ void *internal_start_thread(void(*func)(void *arg), void *arg) {
17121712
#endif
17131713
internal_sigprocmask(SIG_SETMASK, &set, &old);
17141714
void *th;
1715-
real_pthread_create(&th, nullptr, (void*(*)(void *arg))func, arg);
1715+
real_pthread_create(&th, nullptr, func, arg);
17161716
internal_sigprocmask(SIG_SETMASK, &old, nullptr);
17171717
return th;
17181718
}
@@ -1721,7 +1721,7 @@ void internal_join_thread(void *th) {
17211721
real_pthread_join(th, nullptr);
17221722
}
17231723
#else
1724-
void *internal_start_thread(void (*func)(void *), void *arg) { return 0; }
1724+
void *internal_start_thread(void *(*func)(void *), void *arg) { return 0; }
17251725

17261726
void internal_join_thread(void *th) {}
17271727
#endif

compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,13 +677,13 @@ uptr GetRSS() {
677677
return info.resident_size;
678678
}
679679

680-
void *internal_start_thread(void(*func)(void *arg), void *arg) {
680+
void *internal_start_thread(void *(*func)(void *arg), void *arg) {
681681
// Start the thread with signals blocked, otherwise it can steal user signals.
682682
__sanitizer_sigset_t set, old;
683683
internal_sigfillset(&set);
684684
internal_sigprocmask(SIG_SETMASK, &set, &old);
685685
pthread_t th;
686-
pthread_create(&th, 0, (void*(*)(void *arg))func, arg);
686+
pthread_create(&th, 0, func, arg);
687687
internal_sigprocmask(SIG_SETMASK, &old, 0);
688688
return th;
689689
}

compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_mac.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct RunThreadArgs {
5050
void *argument;
5151
};
5252

53-
void RunThread(void *arg) {
53+
void *RunThread(void *arg) {
5454
struct RunThreadArgs *run_args = (struct RunThreadArgs *)arg;
5555
SuspendedThreadsListMac suspended_threads_list;
5656

@@ -59,7 +59,7 @@ void RunThread(void *arg) {
5959
kern_return_t err = task_threads(mach_task_self(), &threads, &num_threads);
6060
if (err != KERN_SUCCESS) {
6161
VReport(1, "Failed to get threads for task (errno %d).\n", err);
62-
return;
62+
return nullptr;
6363
}
6464

6565
thread_t thread_self = mach_thread_self();
@@ -76,6 +76,7 @@ void RunThread(void *arg) {
7676
for (unsigned int i = 0; i < num_suspended; ++i) {
7777
thread_resume(suspended_threads_list.GetThread(i));
7878
}
79+
return nullptr;
7980
}
8081

8182
void StopTheWorld(StopTheWorldCallback callback, void *argument) {

compiler-rt/lib/sanitizer_common/sanitizer_win.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ uptr GetRSS() {
787787
return counters.WorkingSetSize;
788788
}
789789

790-
void *internal_start_thread(void (*func)(void *arg), void *arg) { return 0; }
790+
void *internal_start_thread(void *(*func)(void *arg), void *arg) { return 0; }
791791
void internal_join_thread(void *th) { }
792792

793793
// ---------------------- BlockingMutex ---------------- {{{1

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static void MemoryProfiler(Context *ctx, fd_t fd, int i) {
144144
WriteToFile(fd, buf.data(), internal_strlen(buf.data()));
145145
}
146146

147-
static void BackgroundThread(void *arg) {
147+
static void *BackgroundThread(void *arg) {
148148
// This is a non-initialized non-user thread, nothing to see here.
149149
// We don't use ScopedIgnoreInterceptors, because we want ignores to be
150150
// enabled even when the thread function exits (e.g. during pthread thread
@@ -220,6 +220,7 @@ static void BackgroundThread(void *arg) {
220220
}
221221
}
222222
}
223+
return nullptr;
223224
}
224225

225226
static void StartBackgroundThread() {

0 commit comments

Comments
 (0)