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