Skip to content

Commit

Permalink
asan: don't use thread user_id
Browse files Browse the repository at this point in the history
asan does not use user_id for anything,
so don't pass it to ThreadCreate.
Passing a random uninitialized field of AsanThread
as user_id does not make much sense anyway.

Depends on D113921.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D113922
  • Loading branch information
dvyukov committed Nov 17, 2021
1 parent d1f72f0 commit bdabf3c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
12 changes: 4 additions & 8 deletions compiler-rt/lib/asan/asan_fuchsia.cpp
Expand Up @@ -118,14 +118,12 @@ struct AsanThread::InitOptions {

// Shared setup between thread creation and startup for the initial thread.
static AsanThread *CreateAsanThread(StackTrace *stack, u32 parent_tid,
uptr user_id, bool detached,
const char *name) {
bool detached, const char *name) {
// In lieu of AsanThread::Create.
AsanThread *thread = (AsanThread *)MmapOrDie(AsanThreadMmapSize(), __func__);

AsanThreadContext::CreateThreadContextArgs args = {thread, stack};
u32 tid =
asanThreadRegistry().CreateThread(user_id, detached, parent_tid, &args);
u32 tid = asanThreadRegistry().CreateThread(0, detached, parent_tid, &args);
asanThreadRegistry().SetThreadName(tid, name);

return thread;
Expand All @@ -147,12 +145,11 @@ void AsanThread::SetThreadStackAndTls(const AsanThread::InitOptions *options) {

// Called by __asan::AsanInitInternal (asan_rtl.c).
AsanThread *CreateMainThread() {
thrd_t self = thrd_current();
char name[ZX_MAX_NAME_LEN];
CHECK_NE(__sanitizer::MainThreadStackBase, 0);
CHECK_GT(__sanitizer::MainThreadStackSize, 0);
AsanThread *t = CreateAsanThread(
nullptr, 0, reinterpret_cast<uptr>(self), true,
nullptr, 0, true,
_zx_object_get_property(thrd_get_zx_handle(self), ZX_PROP_NAME, name,
sizeof(name)) == ZX_OK
? name
Expand Down Expand Up @@ -182,8 +179,7 @@ static void *BeforeThreadCreateHook(uptr user_id, bool detached,
GET_STACK_TRACE_THREAD;
u32 parent_tid = GetCurrentTidOrInvalid();

AsanThread *thread =
CreateAsanThread(&stack, parent_tid, user_id, detached, name);
AsanThread *thread = CreateAsanThread(&stack, parent_tid, detached, name);

// On other systems, AsanThread::Init() is called from the new
// thread itself. But on Fuchsia we already know the stack address
Expand Down
3 changes: 1 addition & 2 deletions compiler-rt/lib/asan/asan_thread.cpp
Expand Up @@ -83,8 +83,7 @@ AsanThread *AsanThread::Create(thread_callback_t start_routine, void *arg,
thread->start_routine_ = start_routine;
thread->arg_ = arg;
AsanThreadContext::CreateThreadContextArgs args = {thread, stack};
asanThreadRegistry().CreateThread(*reinterpret_cast<uptr *>(thread), detached,
parent_tid, &args);
asanThreadRegistry().CreateThread(0, detached, parent_tid, &args);

return thread;
}
Expand Down

0 comments on commit bdabf3c

Please sign in to comment.