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

Unified Diff: runtime/vm/isolate.cc

Issue 932983002: To satisfy ASAN, use stub instead of & operator to get C++ stack pointer. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 10 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 | « runtime/vm/isolate.h ('k') | runtime/vm/simulator_arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/isolate.cc
===================================================================
--- runtime/vm/isolate.cc (revision 43859)
+++ runtime/vm/isolate.cc (working copy)
@@ -624,7 +624,7 @@
}
-Isolate* Isolate::Init(const char* name_prefix) {
+Isolate* Isolate::Init(const char* name_prefix, bool is_vm_isolate) {
Isolate* result = new Isolate();
ASSERT(result != NULL);
@@ -654,11 +654,11 @@
ASSERT(state != NULL);
result->set_api_state(state);
- // Initialize stack top and limit in case we are running the isolate in the
- // main thread.
- // TODO(5411455): Need to figure out how to set the stack limit for the
- // main thread.
- result->SetStackLimitFromStackBase(reinterpret_cast<uword>(&result));
+ // Initialize stack limit (wait until later for the VM isolate, since the
+ // needed GetStackPointer stub has not yet been generated in that case).
+ if (!is_vm_isolate) {
+ result->InitializeStackLimit();
+ }
result->set_main_port(PortMap::CreatePort(result->message_handler()));
#if defined(DEBUG)
// Verify that we are never reusing a live origin id.
@@ -687,6 +687,32 @@
}
+void Isolate::InitializeStackLimit() {
+ SetStackLimitFromStackBase(Isolate::GetCurrentStackPointer());
+}
+
+
+/* static */
+uword Isolate::GetCurrentStackPointer() {
+ // Since AddressSanitizer's detect_stack_use_after_return instruments the
+ // C++ code to give out fake stack addresses, we call a stub in that case.
+ uword (*func)() =
+ reinterpret_cast<uword (*)()>(StubCode::GetStackPointerEntryPoint());
+ // But for performance (and to support simulators), we normally use a local.
+ uword stack_allocated_local_address = reinterpret_cast<uword>(&func);
+#if defined(__has_feature)
+#if __has_feature(address_sanitizer)
+ uword current_sp = func();
+ return current_sp;
+#else
+ return stack_allocated_local_address;
+#endif
+#else
+ return stack_allocated_local_address;
+#endif
+}
+
+
void Isolate::BuildName(const char* name_prefix) {
ASSERT(name_ == NULL);
if (name_prefix == NULL) {
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/simulator_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698