@@ -28,7 +28,7 @@ namespace __asan {
28
28
// AsanThreadContext implementation.
29
29
30
30
void AsanThreadContext::OnCreated (void *arg) {
31
- CreateThreadContextArgs *args = static_cast <CreateThreadContextArgs*>(arg);
31
+ CreateThreadContextArgs *args = static_cast <CreateThreadContextArgs *>(arg);
32
32
if (args->stack )
33
33
stack_id = StackDepotPut (*args->stack );
34
34
thread = args->thread ;
@@ -49,7 +49,7 @@ static LowLevelAllocator allocator_for_thread_context;
49
49
50
50
static ThreadContextBase *GetAsanThreadContext (u32 tid) {
51
51
Lock lock (&mu_for_thread_context);
52
- return new (allocator_for_thread_context) AsanThreadContext (tid);
52
+ return new (allocator_for_thread_context) AsanThreadContext (tid);
53
53
}
54
54
55
55
ThreadRegistry &asanThreadRegistry () {
@@ -80,7 +80,7 @@ AsanThread *AsanThread::Create(thread_callback_t start_routine, void *arg,
80
80
bool detached) {
81
81
uptr PageSize = GetPageSizeCached ();
82
82
uptr size = RoundUpTo (sizeof (AsanThread), PageSize);
83
- AsanThread *thread = (AsanThread*)MmapOrDie (size, __func__);
83
+ AsanThread *thread = (AsanThread *)MmapOrDie (size, __func__);
84
84
thread->start_routine_ = start_routine;
85
85
thread->arg_ = arg;
86
86
AsanThreadContext::CreateThreadContextArgs args = {thread, stack};
@@ -90,7 +90,7 @@ AsanThread *AsanThread::Create(thread_callback_t start_routine, void *arg,
90
90
}
91
91
92
92
void AsanThread::TSDDtor (void *tsd) {
93
- AsanThreadContext *context = (AsanThreadContext*)tsd;
93
+ AsanThreadContext *context = (AsanThreadContext *)tsd;
94
94
VReport (1 , " T%d TSDDtor\n " , context->tid );
95
95
if (context->thread )
96
96
context->thread ->Destroy ();
@@ -144,8 +144,7 @@ void AsanThread::StartSwitchFiber(FakeStack **fake_stack_save, uptr bottom,
144
144
current_fake_stack->Destroy (this ->tid ());
145
145
}
146
146
147
- void AsanThread::FinishSwitchFiber (FakeStack *fake_stack_save,
148
- uptr *bottom_old,
147
+ void AsanThread::FinishSwitchFiber (FakeStack *fake_stack_save, uptr *bottom_old,
149
148
uptr *size_old) {
150
149
if (!atomic_load (&stack_switching_, memory_order_relaxed)) {
151
150
Report (" ERROR: finishing a fiber switch that has not started\n " );
@@ -171,7 +170,8 @@ void AsanThread::FinishSwitchFiber(FakeStack *fake_stack_save,
171
170
inline AsanThread::StackBounds AsanThread::GetStackBounds () const {
172
171
if (!atomic_load (&stack_switching_, memory_order_acquire)) {
173
172
// Make sure the stack bounds are fully initialized.
174
- if (stack_bottom_ >= stack_top_) return {0 , 0 };
173
+ if (stack_bottom_ >= stack_top_)
174
+ return {0 , 0 };
175
175
return {stack_bottom_, stack_top_};
176
176
}
177
177
char local;
@@ -184,13 +184,9 @@ inline AsanThread::StackBounds AsanThread::GetStackBounds() const {
184
184
return {stack_bottom_, stack_top_};
185
185
}
186
186
187
- uptr AsanThread::stack_top () {
188
- return GetStackBounds ().top ;
189
- }
187
+ uptr AsanThread::stack_top () { return GetStackBounds ().top ; }
190
188
191
- uptr AsanThread::stack_bottom () {
192
- return GetStackBounds ().bottom ;
193
- }
189
+ uptr AsanThread::stack_bottom () { return GetStackBounds ().bottom ; }
194
190
195
191
uptr AsanThread::stack_size () {
196
192
const auto bounds = GetStackBounds ();
@@ -211,8 +207,8 @@ FakeStack *AsanThread::AsyncSignalSafeLazyInitFakeStack() {
211
207
// This CAS checks if the state was 0 and if so changes it to state 1,
212
208
// if that was successful, it initializes the pointer.
213
209
if (atomic_compare_exchange_strong (
214
- reinterpret_cast <atomic_uintptr_t *>(&fake_stack_), &old_val, 1UL ,
215
- memory_order_relaxed)) {
210
+ reinterpret_cast <atomic_uintptr_t *>(&fake_stack_), &old_val, 1UL ,
211
+ memory_order_relaxed)) {
216
212
uptr stack_size_log = Log2 (RoundUpToPowerOfTwo (stack_size));
217
213
CHECK_LE (flags ()->min_uar_stack_size_log , flags ()->max_uar_stack_size_log );
218
214
stack_size_log =
@@ -265,7 +261,8 @@ thread_return_t AsanThread::ThreadStart(tid_t os_id) {
265
261
Init ();
266
262
asanThreadRegistry ().StartThread (tid (), os_id, ThreadType::Regular, nullptr );
267
263
268
- if (common_flags ()->use_sigaltstack ) SetAlternateSignalStack ();
264
+ if (common_flags ()->use_sigaltstack )
265
+ SetAlternateSignalStack ();
269
266
270
267
if (!start_routine_) {
271
268
// start_routine_ == 0 if we're on the main thread or on one of the
@@ -341,14 +338,14 @@ bool AsanThread::GetStackFrameAccessByAddr(uptr addr,
341
338
bottom = fake_stack->AddrIsInFakeStack (addr);
342
339
CHECK (bottom);
343
340
access->offset = addr - bottom;
344
- access->frame_pc = ((uptr*)bottom)[2 ];
345
- access->frame_descr = (const char *)((uptr*)bottom)[1 ];
341
+ access->frame_pc = ((uptr *)bottom)[2 ];
342
+ access->frame_descr = (const char *)((uptr *)bottom)[1 ];
346
343
return true ;
347
344
}
348
345
uptr aligned_addr = RoundDownTo (addr, SANITIZER_WORDSIZE / 8 ); // align addr.
349
346
uptr mem_ptr = RoundDownTo (aligned_addr, ASAN_SHADOW_GRANULARITY);
350
- u8 *shadow_ptr = (u8 *)MemToShadow (aligned_addr);
351
- u8 *shadow_bottom = (u8 *)MemToShadow (bottom);
347
+ u8 *shadow_ptr = (u8 *)MemToShadow (aligned_addr);
348
+ u8 *shadow_bottom = (u8 *)MemToShadow (bottom);
352
349
353
350
while (shadow_ptr >= shadow_bottom &&
354
351
*shadow_ptr != kAsanStackLeftRedzoneMagic ) {
@@ -370,7 +367,7 @@ bool AsanThread::GetStackFrameAccessByAddr(uptr addr,
370
367
CHECK (ptr[0 ] == kCurrentStackFrameMagic );
371
368
access->offset = addr - (uptr)ptr;
372
369
access->frame_pc = ptr[2 ];
373
- access->frame_descr = (const char *)ptr[1 ];
370
+ access->frame_descr = (const char *)ptr[1 ];
374
371
return true ;
375
372
}
376
373
@@ -388,8 +385,8 @@ uptr AsanThread::GetStackVariableShadowStart(uptr addr) {
388
385
}
389
386
390
387
uptr aligned_addr = RoundDownTo (addr, SANITIZER_WORDSIZE / 8 ); // align addr.
391
- u8 *shadow_ptr = (u8 *)MemToShadow (aligned_addr);
392
- u8 *shadow_bottom = (u8 *)MemToShadow (bottom);
388
+ u8 *shadow_ptr = (u8 *)MemToShadow (aligned_addr);
389
+ u8 *shadow_bottom = (u8 *)MemToShadow (bottom);
393
390
394
391
while (shadow_ptr >= shadow_bottom &&
395
392
(*shadow_ptr != kAsanStackLeftRedzoneMagic &&
@@ -473,10 +470,11 @@ void EnsureMainThreadIDIsCorrect() {
473
470
__asan::AsanThread *GetAsanThreadByOsIDLocked (tid_t os_id) {
474
471
__asan::AsanThreadContext *context = static_cast <__asan::AsanThreadContext *>(
475
472
__asan::asanThreadRegistry ().FindThreadContextByOsIDLocked (os_id));
476
- if (!context) return nullptr ;
473
+ if (!context)
474
+ return nullptr ;
477
475
return context->thread ;
478
476
}
479
- } // namespace __asan
477
+ } // namespace __asan
480
478
481
479
// --- Implementation of LSan-specific functions --- {{{1
482
480
namespace __lsan {
@@ -495,7 +493,8 @@ bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end,
495
493
uptr *tls_begin, uptr *tls_end, uptr *cache_begin,
496
494
uptr *cache_end, DTLS **dtls) {
497
495
__asan::AsanThread *t = __asan::GetAsanThreadByOsIDLocked (os_id);
498
- if (!t) return false ;
496
+ if (!t)
497
+ return false ;
499
498
*stack_begin = t->stack_bottom ();
500
499
*stack_end = t->stack_top ();
501
500
*tls_begin = t->tls_begin ();
@@ -579,7 +578,7 @@ void FinishThreadLocked(u32 tid) {
579
578
GetAsanThreadRegistryLocked ()->FinishThread (tid);
580
579
}
581
580
582
- } // namespace __lsan
581
+ } // namespace __lsan
583
582
584
583
// ---------------------- Interface ---------------- {{{1
585
584
using namespace __asan ;
@@ -593,20 +592,18 @@ void __sanitizer_start_switch_fiber(void **fakestacksave, const void *bottom,
593
592
VReport (1 , " __asan_start_switch_fiber called from unknown thread\n " );
594
593
return ;
595
594
}
596
- t->StartSwitchFiber ((FakeStack**)fakestacksave, (uptr)bottom, size);
595
+ t->StartSwitchFiber ((FakeStack **)fakestacksave, (uptr)bottom, size);
597
596
}
598
597
599
598
SANITIZER_INTERFACE_ATTRIBUTE
600
- void __sanitizer_finish_switch_fiber (void * fakestack,
601
- const void **bottom_old,
599
+ void __sanitizer_finish_switch_fiber (void *fakestack, const void **bottom_old,
602
600
uptr *size_old) {
603
601
AsanThread *t = GetCurrentThread ();
604
602
if (!t) {
605
603
VReport (1 , " __asan_finish_switch_fiber called from unknown thread\n " );
606
604
return ;
607
605
}
608
- t->FinishSwitchFiber ((FakeStack*)fakestack,
609
- (uptr*)bottom_old,
610
- (uptr*)size_old);
606
+ t->FinishSwitchFiber ((FakeStack *)fakestack, (uptr *)bottom_old,
607
+ (uptr *)size_old);
611
608
}
612
609
}
0 commit comments