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

Unified 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, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/ThreadState.cpp
diff --git a/Source/platform/heap/ThreadState.cpp b/Source/platform/heap/ThreadState.cpp
index c2f084bfb62eb986ef8d83159ae9634340eabdd0..5392886032fb4090466c24130fd62d3923fcc9c6 100644
--- a/Source/platform/heap/ThreadState.cpp
+++ b/Source/platform/heap/ThreadState.cpp
@@ -242,6 +242,9 @@ ThreadState::ThreadState()
, m_inGC(false)
, m_heapContainsCache(adoptPtr(new HeapContainsCache()))
, m_isCleaningUp(false)
+#if defined(ADDRESS_SANITIZER) && !OS(WIN)
+ , m_asanFakeStack(__asan_get_current_fake_stack())
+#endif
{
ASSERT(!**s_threadSpecific);
**s_threadSpecific = this;
@@ -344,6 +347,34 @@ void ThreadState::visitRoots(Visitor* visitor)
}
NO_SANITIZE_ADDRESS
+void ThreadState::visitAsanFakeStackForPointer(Visitor* visitor, Address ptr)
+{
+#if defined(ADDRESS_SANITIZER) && !OS(WIN)
+ Address* start = reinterpret_cast<Address*>(m_startOfStack);
+ Address* end = reinterpret_cast<Address*>(m_endOfStack);
+ Address* fakeFrameStart = 0;
+ Address* fakeFrameEnd = 0;
+ Address* maybeFakeFrame = reinterpret_cast<Address*>(ptr);
+ Address* realFrameForFakeFrame =
+ reinterpret_cast<Address*>(
+ __asan_addr_is_in_fake_stack(
+ m_asanFakeStack, maybeFakeFrame,
+ reinterpret_cast<void**>(&fakeFrameStart),
+ reinterpret_cast<void**>(&fakeFrameEnd)));
+ if (realFrameForFakeFrame) {
+ // This is a fake frame from the asan fake stack.
+ if (realFrameForFakeFrame > end && start > realFrameForFakeFrame) {
+ // The real stack address for the asan fake frame is
+ // within the stack range that we need to scan so we need
+ // to visit the values in the fake frame.
+ for (Address* p = fakeFrameStart; p < fakeFrameEnd; p++)
+ Heap::checkAndMarkPointer(visitor, *p);
+ }
+ }
+#endif
+}
+
+NO_SANITIZE_ADDRESS
void ThreadState::visitStack(Visitor* visitor)
{
Address* start = reinterpret_cast<Address*>(m_startOfStack);
@@ -360,11 +391,15 @@ void ThreadState::visitStack(Visitor* visitor)
// will read past start address.
current = reinterpret_cast<Address*>(reinterpret_cast<intptr_t>(current) & ~(sizeof(Address) - 1));
- for (; current < start; ++current)
+ for (; current < start; ++current) {
Heap::checkAndMarkPointer(visitor, *current);
+ visitAsanFakeStackForPointer(visitor, *current);
+ }
- for (Vector<Address>::iterator it = m_safePointStackCopy.begin(); it != m_safePointStackCopy.end(); ++it)
+ for (Vector<Address>::iterator it = m_safePointStackCopy.begin(); it != m_safePointStackCopy.end(); ++it) {
Heap::checkAndMarkPointer(visitor, *it);
+ visitAsanFakeStackForPointer(visitor, *it);
+ }
}
void ThreadState::visitPersistents(Visitor* visitor)
« 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