Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: Source/platform/heap/ThreadState.cpp

Issue 141713008: Use new ASAN APIs for scanning ASAN fake stacks during garbage collection. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase and disable strict finalization checking. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 , m_atSafePoint(false) 235 , m_atSafePoint(false)
236 , m_interruptors() 236 , m_interruptors()
237 , m_gcRequested(false) 237 , m_gcRequested(false)
238 , m_forcePreciseGCForTesting(false) 238 , m_forcePreciseGCForTesting(false)
239 , m_sweepRequested(0) 239 , m_sweepRequested(0)
240 , m_sweepInProgress(false) 240 , m_sweepInProgress(false)
241 , m_noAllocationCount(0) 241 , m_noAllocationCount(0)
242 , m_inGC(false) 242 , m_inGC(false)
243 , m_heapContainsCache(adoptPtr(new HeapContainsCache())) 243 , m_heapContainsCache(adoptPtr(new HeapContainsCache()))
244 , m_isCleaningUp(false) 244 , m_isCleaningUp(false)
245 #if defined(ADDRESS_SANITIZER) && !OS(WIN)
246 , m_asanFakeStack(__asan_get_current_fake_stack())
247 #endif
245 { 248 {
246 ASSERT(!**s_threadSpecific); 249 ASSERT(!**s_threadSpecific);
247 **s_threadSpecific = this; 250 **s_threadSpecific = this;
248 251
249 m_stats.clear(); 252 m_stats.clear();
250 m_statsAfterLastGC.clear(); 253 m_statsAfterLastGC.clear();
251 // First allocate the general heap, second iterate through to 254 // First allocate the general heap, second iterate through to
252 // allocate the type specific heaps 255 // allocate the type specific heaps
253 m_heaps[GeneralHeap] = new ThreadHeap<FinalizedHeapObjectHeader>(this); 256 m_heaps[GeneralHeap] = new ThreadHeap<FinalizedHeapObjectHeader>(this);
254 for (int i = GeneralHeap + 1; i < NumberOfHeaps; i++) 257 for (int i = GeneralHeap + 1; i < NumberOfHeaps; i++)
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 MutexLocker locker(globalRootsMutex()); 340 MutexLocker locker(globalRootsMutex());
338 globalRoots()->trace(visitor); 341 globalRoots()->trace(visitor);
339 } 342 }
340 343
341 AttachedThreadStateSet& threads = attachedThreads(); 344 AttachedThreadStateSet& threads = attachedThreads();
342 for (AttachedThreadStateSet::iterator it = threads.begin(), end = threads.en d(); it != end; ++it) 345 for (AttachedThreadStateSet::iterator it = threads.begin(), end = threads.en d(); it != end; ++it)
343 (*it)->trace(visitor); 346 (*it)->trace(visitor);
344 } 347 }
345 348
346 NO_SANITIZE_ADDRESS 349 NO_SANITIZE_ADDRESS
350 void ThreadState::visitAsanFakeStackForPointer(Visitor* visitor, Address ptr)
351 {
352 #if defined(ADDRESS_SANITIZER) && !OS(WIN)
353 Address* start = reinterpret_cast<Address*>(m_startOfStack);
354 Address* end = reinterpret_cast<Address*>(m_endOfStack);
355 Address* fakeFrameStart = 0;
356 Address* fakeFrameEnd = 0;
357 Address* maybeFakeFrame = reinterpret_cast<Address*>(ptr);
358 Address* realFrameForFakeFrame =
359 reinterpret_cast<Address*>(
360 __asan_addr_is_in_fake_stack(
361 m_asanFakeStack, maybeFakeFrame,
362 reinterpret_cast<void**>(&fakeFrameStart),
363 reinterpret_cast<void**>(&fakeFrameEnd)));
364 if (realFrameForFakeFrame) {
365 // This is a fake frame from the asan fake stack.
366 if (realFrameForFakeFrame > end && start > realFrameForFakeFrame) {
367 // The real stack address for the asan fake frame is
368 // within the stack range that we need to scan so we need
369 // to visit the values in the fake frame.
370 for (Address* p = fakeFrameStart; p < fakeFrameEnd; p++)
371 Heap::checkAndMarkPointer(visitor, *p);
372 }
373 }
374 #endif
375 }
376
377 NO_SANITIZE_ADDRESS
347 void ThreadState::visitStack(Visitor* visitor) 378 void ThreadState::visitStack(Visitor* visitor)
348 { 379 {
349 Address* start = reinterpret_cast<Address*>(m_startOfStack); 380 Address* start = reinterpret_cast<Address*>(m_startOfStack);
350 // If there is a safepoint scope marker we should stop the stack 381 // If there is a safepoint scope marker we should stop the stack
351 // scanning there to not touch active parts of the stack. Anything 382 // scanning there to not touch active parts of the stack. Anything
352 // interesting beyond that point is in the safepoint stack copy. 383 // interesting beyond that point is in the safepoint stack copy.
353 // If there is no scope marker the thread is blocked and we should 384 // If there is no scope marker the thread is blocked and we should
354 // scan all the way to the recorded end stack pointer. 385 // scan all the way to the recorded end stack pointer.
355 Address* end = reinterpret_cast<Address*>(m_endOfStack); 386 Address* end = reinterpret_cast<Address*>(m_endOfStack);
356 Address* safePointScopeMarker = reinterpret_cast<Address*>(m_safePointScopeM arker); 387 Address* safePointScopeMarker = reinterpret_cast<Address*>(m_safePointScopeM arker);
357 Address* current = safePointScopeMarker ? safePointScopeMarker : end; 388 Address* current = safePointScopeMarker ? safePointScopeMarker : end;
358 389
359 // Ensure that current is aligned by address size otherwise the loop below 390 // Ensure that current is aligned by address size otherwise the loop below
360 // will read past start address. 391 // will read past start address.
361 current = reinterpret_cast<Address*>(reinterpret_cast<intptr_t>(current) & ~ (sizeof(Address) - 1)); 392 current = reinterpret_cast<Address*>(reinterpret_cast<intptr_t>(current) & ~ (sizeof(Address) - 1));
362 393
363 for (; current < start; ++current) 394 for (; current < start; ++current) {
364 Heap::checkAndMarkPointer(visitor, *current); 395 Heap::checkAndMarkPointer(visitor, *current);
396 visitAsanFakeStackForPointer(visitor, *current);
397 }
365 398
366 for (Vector<Address>::iterator it = m_safePointStackCopy.begin(); it != m_sa fePointStackCopy.end(); ++it) 399 for (Vector<Address>::iterator it = m_safePointStackCopy.begin(); it != m_sa fePointStackCopy.end(); ++it) {
367 Heap::checkAndMarkPointer(visitor, *it); 400 Heap::checkAndMarkPointer(visitor, *it);
401 visitAsanFakeStackForPointer(visitor, *it);
402 }
368 } 403 }
369 404
370 void ThreadState::visitPersistents(Visitor* visitor) 405 void ThreadState::visitPersistents(Visitor* visitor)
371 { 406 {
372 m_persistents->trace(visitor); 407 m_persistents->trace(visitor);
373 } 408 }
374 409
375 void ThreadState::trace(Visitor* visitor) 410 void ThreadState::trace(Visitor* visitor)
376 { 411 {
377 if (m_stackState == HeapPointersOnStack) 412 if (m_stackState == HeapPointersOnStack)
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 state->safePoint(HeapPointersOnStack); 772 state->safePoint(HeapPointersOnStack);
738 } 773 }
739 774
740 ThreadState::AttachedThreadStateSet& ThreadState::attachedThreads() 775 ThreadState::AttachedThreadStateSet& ThreadState::attachedThreads()
741 { 776 {
742 DEFINE_STATIC_LOCAL(AttachedThreadStateSet, threads, ()); 777 DEFINE_STATIC_LOCAL(AttachedThreadStateSet, threads, ());
743 return threads; 778 return threads;
744 } 779 }
745 780
746 } 781 }
OLDNEW
« no previous file with comments | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698