Change internal_start_thread arguments to match pthread_create.

This avoids a CFI-unfriendly function pointer type cast in
internal_start_thread.
This commit is contained in:
Evgenii Stepanov 2020-01-23 13:01:08 -08:00
parent 9d9b470e69
commit 966b5182ba
7 changed files with 13 additions and 11 deletions

View File

@ -855,7 +855,7 @@ INLINE uptr GetPthreadDestructorIterations() {
#endif
}
void *internal_start_thread(void(*func)(void*), void *arg);
void *internal_start_thread(void *(*func)(void*), void *arg);
void internal_join_thread(void *th);
void MaybeStartBackgroudThread();

View File

@ -30,7 +30,7 @@ SANITIZER_WEAK_ATTRIBUTE StackDepotStats *StackDepotGetStats() {
return nullptr;
}
void BackgroundThread(void *arg) {
void *BackgroundThread(void *arg) {
const uptr hard_rss_limit_mb = common_flags()->hard_rss_limit_mb;
const uptr soft_rss_limit_mb = common_flags()->soft_rss_limit_mb;
const bool heap_profile = common_flags()->heap_profile;

View File

@ -1701,7 +1701,7 @@ HandleSignalMode GetHandleSignalMode(int signum) {
}
#if !SANITIZER_GO
void *internal_start_thread(void(*func)(void *arg), void *arg) {
void *internal_start_thread(void *(*func)(void *arg), void *arg) {
// Start the thread with signals blocked, otherwise it can steal user signals.
__sanitizer_sigset_t set, old;
internal_sigfillset(&set);
@ -1712,7 +1712,7 @@ void *internal_start_thread(void(*func)(void *arg), void *arg) {
#endif
internal_sigprocmask(SIG_SETMASK, &set, &old);
void *th;
real_pthread_create(&th, nullptr, (void*(*)(void *arg))func, arg);
real_pthread_create(&th, nullptr, func, arg);
internal_sigprocmask(SIG_SETMASK, &old, nullptr);
return th;
}
@ -1721,7 +1721,7 @@ void internal_join_thread(void *th) {
real_pthread_join(th, nullptr);
}
#else
void *internal_start_thread(void (*func)(void *), void *arg) { return 0; }
void *internal_start_thread(void *(*func)(void *), void *arg) { return 0; }
void internal_join_thread(void *th) {}
#endif

View File

@ -677,13 +677,13 @@ uptr GetRSS() {
return info.resident_size;
}
void *internal_start_thread(void(*func)(void *arg), void *arg) {
void *internal_start_thread(void *(*func)(void *arg), void *arg) {
// Start the thread with signals blocked, otherwise it can steal user signals.
__sanitizer_sigset_t set, old;
internal_sigfillset(&set);
internal_sigprocmask(SIG_SETMASK, &set, &old);
pthread_t th;
pthread_create(&th, 0, (void*(*)(void *arg))func, arg);
pthread_create(&th, 0, func, arg);
internal_sigprocmask(SIG_SETMASK, &old, 0);
return th;
}

View File

@ -50,7 +50,7 @@ struct RunThreadArgs {
void *argument;
};
void RunThread(void *arg) {
void *RunThread(void *arg) {
struct RunThreadArgs *run_args = (struct RunThreadArgs *)arg;
SuspendedThreadsListMac suspended_threads_list;
@ -59,7 +59,7 @@ void RunThread(void *arg) {
kern_return_t err = task_threads(mach_task_self(), &threads, &num_threads);
if (err != KERN_SUCCESS) {
VReport(1, "Failed to get threads for task (errno %d).\n", err);
return;
return nullptr;
}
thread_t thread_self = mach_thread_self();
@ -76,6 +76,7 @@ void RunThread(void *arg) {
for (unsigned int i = 0; i < num_suspended; ++i) {
thread_resume(suspended_threads_list.GetThread(i));
}
return nullptr;
}
void StopTheWorld(StopTheWorldCallback callback, void *argument) {

View File

@ -787,7 +787,7 @@ uptr GetRSS() {
return counters.WorkingSetSize;
}
void *internal_start_thread(void (*func)(void *arg), void *arg) { return 0; }
void *internal_start_thread(void *(*func)(void *arg), void *arg) { return 0; }
void internal_join_thread(void *th) { }
// ---------------------- BlockingMutex ---------------- {{{1

View File

@ -144,7 +144,7 @@ static void MemoryProfiler(Context *ctx, fd_t fd, int i) {
WriteToFile(fd, buf.data(), internal_strlen(buf.data()));
}
static void BackgroundThread(void *arg) {
static void *BackgroundThread(void *arg) {
// This is a non-initialized non-user thread, nothing to see here.
// We don't use ScopedIgnoreInterceptors, because we want ignores to be
// enabled even when the thread function exits (e.g. during pthread thread
@ -220,6 +220,7 @@ static void BackgroundThread(void *arg) {
}
}
}
return nullptr;
}
static void StartBackgroundThread() {