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

Unified Diff: runtime/vm/exceptions.cc

Issue 15836008: - Unpoison stack for ASan when tearing down stack frames (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/exceptions.cc
===================================================================
--- runtime/vm/exceptions.cc (revision 23509)
+++ runtime/vm/exceptions.cc (working copy)
@@ -14,6 +14,19 @@
#include "vm/stub_code.h"
#include "vm/symbols.h"
+// Allow the use of ASan (AddressSanitizer). This is needed as ASan needs to be
+// told about areas where the VM does the equivalent of a long-jump.
+#if defined(__has_feature)
+#if __has_feature(address_sanitizer)
+extern "C" void __asan_unpoison_memory_region(void *, size_t);
+#else // __has_feature(address_sanitizer)
+void __asan_unpoison_memory_region(void* ignore1, size_t ignore2) {}
+#endif // __has_feature(address_sanitizer)
+#else // defined(__has_feature)
+void __asan_unpoison_memory_region(void* ignore1, size_t ignore2) {}
+#endif // defined(__has_feature)
+
+
namespace dart {
DEFINE_FLAG(bool, print_stacktrace_at_throw, false,
@@ -243,6 +256,11 @@
typedef void (*ExcpHandler)(uword, uword, uword, RawObject*, RawObject*);
ExcpHandler func = reinterpret_cast<ExcpHandler>(
StubCode::JumpToExceptionHandlerEntryPoint());
+
+ // Unpoison the stack before we tear it down in the generated stub code.
+ uword current_sp = reinterpret_cast<uword>(&program_counter) - 1024;
+ __asan_unpoison_memory_region(reinterpret_cast<void*>(current_sp),
Anton Muhin 2013/06/03 12:55:07 nit: as per ASAN source code, one is supposed to u
Anton Muhin 2013/06/03 12:55:07 one hypothetical scenario I am concerned with: 1)
Anton Muhin 2013/06/03 12:55:07 who will poison this region back? I suspect ASAN
Ivan Posva 2013/06/06 17:17:05 Since there are guard pages between stacks, and th
Ivan Posva 2013/06/06 17:17:05 As far as I understand, function entries that are
kcc1 2013/06/07 06:38:45 If you include the asan's header, the macro makes
kcc1 2013/06/07 06:38:45 In theory this may happen, but given the relativel
kcc1 2013/06/07 06:38:45 Once we enter another function it will poison its
Ivan Posva 2013/06/07 15:23:12 That is correct. stack_pointer is the value that w
+ stack_pointer - current_sp);
func(program_counter, stack_pointer, frame_pointer,
raw_exception, raw_stacktrace);
#endif
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698