Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/exceptions.h" | 5 #include "vm/exceptions.h" |
| 6 | 6 |
| 7 #include "vm/dart_api_impl.h" | 7 #include "vm/dart_api_impl.h" |
| 8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
| 9 #include "vm/debugger.h" | 9 #include "vm/debugger.h" |
| 10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
| 11 #include "vm/object.h" | 11 #include "vm/object.h" |
| 12 #include "vm/object_store.h" | 12 #include "vm/object_store.h" |
| 13 #include "vm/stack_frame.h" | 13 #include "vm/stack_frame.h" |
| 14 #include "vm/stub_code.h" | 14 #include "vm/stub_code.h" |
| 15 #include "vm/symbols.h" | 15 #include "vm/symbols.h" |
| 16 | 16 |
| 17 // Allow the use of ASan (AddressSanitizer). This is needed as ASan needs to be | |
| 18 // told about areas where the VM does the equivalent of a long-jump. | |
| 19 #if defined(__has_feature) | |
| 20 #if __has_feature(address_sanitizer) | |
| 21 extern "C" void __asan_unpoison_memory_region(void *, size_t); | |
| 22 #else // __has_feature(address_sanitizer) | |
| 23 void __asan_unpoison_memory_region(void* ignore1, size_t ignore2) {} | |
| 24 #endif // __has_feature(address_sanitizer) | |
| 25 #else // defined(__has_feature) | |
| 26 void __asan_unpoison_memory_region(void* ignore1, size_t ignore2) {} | |
| 27 #endif // defined(__has_feature) | |
| 28 | |
| 29 | |
| 17 namespace dart { | 30 namespace dart { |
| 18 | 31 |
| 19 DEFINE_FLAG(bool, print_stacktrace_at_throw, false, | 32 DEFINE_FLAG(bool, print_stacktrace_at_throw, false, |
| 20 "Prints a stack trace everytime a throw occurs."); | 33 "Prints a stack trace everytime a throw occurs."); |
| 21 DEFINE_FLAG(bool, heap_profile_out_of_memory, false, | 34 DEFINE_FLAG(bool, heap_profile_out_of_memory, false, |
| 22 "Writes a heap profile on unhandled out-of-memory exceptions."); | 35 "Writes a heap profile on unhandled out-of-memory exceptions."); |
| 23 DEFINE_FLAG(bool, verbose_stacktrace, false, | 36 DEFINE_FLAG(bool, verbose_stacktrace, false, |
| 24 "Stack traces will include methods marked invisible."); | 37 "Stack traces will include methods marked invisible."); |
| 25 | 38 |
| 26 const char* Exceptions::kCastErrorDstName = "type cast"; | 39 const char* Exceptions::kCastErrorDstName = "type cast"; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 (reinterpret_cast<uword>(isolate->top_resource()) < stack_pointer)) { | 249 (reinterpret_cast<uword>(isolate->top_resource()) < stack_pointer)) { |
| 237 isolate->top_resource()->~StackResource(); | 250 isolate->top_resource()->~StackResource(); |
| 238 } | 251 } |
| 239 | 252 |
| 240 // Call a stub to set up the exception object in kExceptionObjectReg, | 253 // Call a stub to set up the exception object in kExceptionObjectReg, |
| 241 // to set up the stacktrace object in kStackTraceObjectReg, and to | 254 // to set up the stacktrace object in kStackTraceObjectReg, and to |
| 242 // continue execution at the given pc in the given frame. | 255 // continue execution at the given pc in the given frame. |
| 243 typedef void (*ExcpHandler)(uword, uword, uword, RawObject*, RawObject*); | 256 typedef void (*ExcpHandler)(uword, uword, uword, RawObject*, RawObject*); |
| 244 ExcpHandler func = reinterpret_cast<ExcpHandler>( | 257 ExcpHandler func = reinterpret_cast<ExcpHandler>( |
| 245 StubCode::JumpToExceptionHandlerEntryPoint()); | 258 StubCode::JumpToExceptionHandlerEntryPoint()); |
| 259 | |
| 260 // Unpoison the stack before we tear it down in the generated stub code. | |
| 261 uword current_sp = reinterpret_cast<uword>(&program_counter) - 1024; | |
| 262 __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
| |
| 263 stack_pointer - current_sp); | |
| 246 func(program_counter, stack_pointer, frame_pointer, | 264 func(program_counter, stack_pointer, frame_pointer, |
| 247 raw_exception, raw_stacktrace); | 265 raw_exception, raw_stacktrace); |
| 248 #endif | 266 #endif |
| 249 UNREACHABLE(); | 267 UNREACHABLE(); |
| 250 } | 268 } |
| 251 | 269 |
| 252 | 270 |
| 253 static void ThrowExceptionHelper(const Instance& incoming_exception, | 271 static void ThrowExceptionHelper(const Instance& incoming_exception, |
| 254 const Instance& existing_stacktrace) { | 272 const Instance& existing_stacktrace) { |
| 255 bool use_preallocated_stacktrace = false; | 273 bool use_preallocated_stacktrace = false; |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 606 break; | 624 break; |
| 607 } | 625 } |
| 608 | 626 |
| 609 return DartLibraryCalls::ExceptionCreate(library, | 627 return DartLibraryCalls::ExceptionCreate(library, |
| 610 *class_name, | 628 *class_name, |
| 611 *constructor_name, | 629 *constructor_name, |
| 612 arguments); | 630 arguments); |
| 613 } | 631 } |
| 614 | 632 |
| 615 } // namespace dart | 633 } // namespace dart |
| OLD | NEW |