Skip to content

Commit f7f6f6d

Browse files
authored
[asan] Hide SetTLSFakeStack and replaces uses with ResetTLSFakeStack (#163674)
To simplify implementation of #160135 To keep the logic of figuring out what should be in TLS to one place. The rest of the code should just reset it and rely on GetFakeStackFast()/GetFakeStackFastAlways().
1 parent d70801b commit f7f6f6d

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

compiler-rt/lib/asan/asan_fake_stack.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,12 @@ void FakeStack::ForEachFakeFrame(RangeIteratorCallback callback, void* arg) {
217217
static THREADLOCAL FakeStack* fake_stack_tls;
218218

219219
static FakeStack* GetTLSFakeStack() { return fake_stack_tls; }
220-
void SetTLSFakeStack(FakeStack* fs) { fake_stack_tls = fs; }
220+
static void SetTLSFakeStack(FakeStack* fs) { fake_stack_tls = fs; }
221+
void ResetTLSFakeStack() { fake_stack_tls = nullptr; }
221222
#else
222223
static FakeStack* GetTLSFakeStack() { return nullptr; }
223-
void SetTLSFakeStack(FakeStack* fs) {}
224+
static void SetTLSFakeStack(FakeStack*) {}
225+
void ResetTLSFakeStack() {}
224226
#endif // (SANITIZER_LINUX && !SANITIZER_ANDROID) || SANITIZER_FUCHSIA
225227

226228
static FakeStack* GetFakeStack() {

compiler-rt/lib/asan/asan_fake_stack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class FakeStack {
195195
void *true_start;
196196
};
197197

198-
void SetTLSFakeStack(FakeStack* fs);
198+
void ResetTLSFakeStack();
199199

200200
} // namespace __asan
201201

compiler-rt/lib/asan/asan_thread.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void AsanThread::StartSwitchFiber(FakeStack **fake_stack_save, uptr bottom,
163163
if (fake_stack_save)
164164
*fake_stack_save = fake_stack_;
165165
fake_stack_ = nullptr;
166-
SetTLSFakeStack(nullptr);
166+
ResetTLSFakeStack();
167167
// if fake_stack_save is null, the fiber will die, delete the fakestack
168168
if (!fake_stack_save && current_fake_stack)
169169
current_fake_stack->Destroy(this->tid());
@@ -177,8 +177,8 @@ void AsanThread::FinishSwitchFiber(FakeStack *fake_stack_save, uptr *bottom_old,
177177
}
178178

179179
if (fake_stack_save) {
180-
SetTLSFakeStack(fake_stack_save);
181180
fake_stack_ = fake_stack_save;
181+
ResetTLSFakeStack();
182182
}
183183

184184
if (bottom_old)
@@ -242,7 +242,7 @@ FakeStack *AsanThread::AsyncSignalSafeLazyInitFakeStack() {
242242
Max(stack_size_log, static_cast<uptr>(flags()->min_uar_stack_size_log));
243243
fake_stack_ = FakeStack::Create(stack_size_log);
244244
DCHECK_EQ(GetCurrentThread(), this);
245-
SetTLSFakeStack(fake_stack_);
245+
ResetTLSFakeStack();
246246
return fake_stack_;
247247
}
248248
return nullptr;

compiler-rt/lib/asan/asan_thread.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class AsanThread {
104104
if (!fake_stack_) return;
105105
FakeStack *t = fake_stack_;
106106
fake_stack_ = nullptr;
107-
SetTLSFakeStack(nullptr);
107+
ResetTLSFakeStack();
108108
t->Destroy(tid);
109109
}
110110

0 commit comments

Comments
 (0)