Home | History | Annotate | Download | only in app
      1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "build/build_config.h"
      6 #include "chrome/browser/first_run/upgrade_util.h"
      7 
      8 // The entry point for all invocations of Chromium, browser and renderer. On
      9 // windows, this does nothing but load chrome.dll and invoke its entry point in
     10 // order to make it easy to update the app from GoogleUpdate. We don't need
     11 // that extra layer with on linux.
     12 
     13 #if defined(ADDRESS_SANITIZER) && defined(GOOGLE_CHROME_BUILD)
     14 // Default AddressSanitizer options for the official build. These do not affect
     15 // tests or non-official Chromium builds.
     16 //  - disable the strict memcmp() checking (http://crbug.com/178677 and
     17 //    http://crbug.com/178404).
     18 //  - set the malloc_context_size (i.e. the size of stack traces collected by
     19 //    ASan for each malloc/free) to 5. These stack traces tend to accumulate
     20 //    very fast in applications using JIT (v8 in Chrome's case), see
     21 //    https://code.google.com/p/address-sanitizer/issues/detail?id=177
     22 //  - disable the in-process symbolization, which isn't 100% compatible with
     23 //    the existing sandboxes and doesn't make much sense for stripped official
     24 //    binaries.
     25 const char *kAsanDefaultOptions =
     26     "malloc_context_size=5 strict_memcmp=0 symbolize=false";
     27 
     28 // Override the default ASan options for the Google Chrome executable.
     29 // __asan_default_options should not be instrumented, because it is called
     30 // before ASan is initialized.
     31 extern "C"
     32 __attribute__((no_address_safety_analysis))
     33 const char *__asan_default_options() {
     34   return kAsanDefaultOptions;
     35 }
     36 #endif
     37 
     38 extern "C" {
     39 int ChromeMain(int argc, const char** argv);
     40 }
     41 
     42 int main(int argc, const char** argv) {
     43   int return_code = ChromeMain(argc, argv);
     44 
     45 #if defined(OS_LINUX)
     46   // Launch a new instance if we're shutting down because we detected an
     47   // upgrade in the persistent mode.
     48   upgrade_util::RelaunchChromeBrowserWithNewCommandLineIfNeeded();
     49 #endif
     50 
     51   return return_code;
     52 }
     53