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

Unified Diff: chrome/app/chrome_exe_main_mac.cc

Issue 593683004: Revert of Enable ASan default options on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « build/sanitizers/sanitizers.gyp ('k') | chrome/app/framework.order » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/app/chrome_exe_main_mac.cc
diff --git a/chrome/app/chrome_exe_main_mac.cc b/chrome/app/chrome_exe_main_mac.cc
index 83a5c7c6c8d511cdfd6fee838ad43594208719b5..a0f1ac589e17e1ce165a991d01b5490140755f9e 100644
--- a/chrome/app/chrome_exe_main_mac.cc
+++ b/chrome/app/chrome_exe_main_mac.cc
@@ -5,7 +5,44 @@
// The entry point for all Mac Chromium processes, including the outer app
// bundle (browser) and helper app (renderer, plugin, and friends).
+#if defined(ADDRESS_SANITIZER)
+#include <crt_externs.h> // for _NSGetArgc, _NSGetArgv
+#include <string.h>
+#endif // ADDRESS_SANITIZER
#include <stdlib.h>
+
+#if defined(ADDRESS_SANITIZER)
+// NaCl requires its own SEGV handler, so we need to add handle_segv=0 to
+// ASAN_OPTIONS. This is done by injecting __asan_default_options into the
+// executable.
+// Because there's no distinct NaCl executable on OSX, we have to look at the
+// command line arguments to understand whether the process is a NaCl loader.
+
+static const char kNaClDefaultOptions[] = "handle_segv=0";
+static const char kNaClFlag[] = "--type=nacl-loader";
+
+extern "C"
+// __asan_default_options() is called at ASan initialization, so it must
+// not be instrumented with ASan -- thus the "no_sanitize_address" attribute.
+__attribute__((no_sanitize_address))
+// The function isn't referenced from the executable itself. Make sure it isn't
+// stripped by the linker.
+__attribute__((used))
+__attribute__((visibility("default")))
+const char* __asan_default_options() {
+ char*** argvp = _NSGetArgv();
+ int* argcp = _NSGetArgc();
+ if (!argvp || !argcp) return NULL;
+ char** argv = *argvp;
+ int argc = *argcp;
+ for (int i = 0; i < argc; ++i) {
+ if (strcmp(argv[i], kNaClFlag) == 0) {
+ return kNaClDefaultOptions;
+ }
+ }
+ return NULL;
+}
+#endif // ADDRESS_SANITIZER
extern "C" {
int ChromeMain(int argc, char** argv);
« no previous file with comments | « build/sanitizers/sanitizers.gyp ('k') | chrome/app/framework.order » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698