OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "app/app_paths.h" | 5 #include "app/app_paths.h" |
6 #include "app/app_switches.h" | 6 #include "app/app_switches.h" |
7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/debugger.h" | 10 #include "base/debug/debugger.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 128 |
129 CAppModule _Module; | 129 CAppModule _Module; |
130 | 130 |
131 #pragma optimize("", off) | 131 #pragma optimize("", off) |
132 // Handlers for invalid parameter and pure call. They generate a breakpoint to | 132 // Handlers for invalid parameter and pure call. They generate a breakpoint to |
133 // tell breakpad that it needs to dump the process. | 133 // tell breakpad that it needs to dump the process. |
134 void InvalidParameter(const wchar_t* expression, const wchar_t* function, | 134 void InvalidParameter(const wchar_t* expression, const wchar_t* function, |
135 const wchar_t* file, unsigned int line, | 135 const wchar_t* file, unsigned int line, |
136 uintptr_t reserved) { | 136 uintptr_t reserved) { |
137 __debugbreak(); | 137 __debugbreak(); |
| 138 _exit(1); |
138 } | 139 } |
139 | 140 |
140 void PureCall() { | 141 void PureCall() { |
141 __debugbreak(); | 142 __debugbreak(); |
| 143 _exit(1); |
142 } | 144 } |
143 | 145 |
144 #pragma warning(push) | 146 #pragma warning(push) |
145 // Disables warning 4748 which is: "/GS can not protect parameters and local | 147 // Disables warning 4748 which is: "/GS can not protect parameters and local |
146 // variables from local buffer overrun because optimizations are disabled in | 148 // variables from local buffer overrun because optimizations are disabled in |
147 // function." GetStats() will not overflow the passed-in buffer and this | 149 // function." GetStats() will not overflow the passed-in buffer and this |
148 // function never returns. | 150 // function never returns. |
149 #pragma warning(disable : 4748) | 151 #pragma warning(disable : 4748) |
150 void OnNoMemory() { | 152 void OnNoMemory() { |
151 #if defined(USE_TCMALLOC) | 153 #if defined(USE_TCMALLOC) |
152 // Try to get some information on the stack to make the crash easier to | 154 // Try to get some information on the stack to make the crash easier to |
153 // diagnose from a minidump, being very careful not to do anything that might | 155 // diagnose from a minidump, being very careful not to do anything that might |
154 // try to heap allocate. | 156 // try to heap allocate. |
155 char buf[32*1024]; | 157 char buf[32*1024]; |
156 MallocExtension::instance()->GetStats(buf, sizeof(buf)); | 158 MallocExtension::instance()->GetStats(buf, sizeof(buf)); |
157 #endif | 159 #endif |
158 // Kill the process. This is important for security, since WebKit doesn't | 160 // Kill the process. This is important for security, since WebKit doesn't |
159 // NULL-check many memory allocations. If a malloc fails, returns NULL, and | 161 // NULL-check many memory allocations. If a malloc fails, returns NULL, and |
160 // the buffer is then used, it provides a handy mapping of memory starting at | 162 // the buffer is then used, it provides a handy mapping of memory starting at |
161 // address 0 for an attacker to utilize. | 163 // address 0 for an attacker to utilize. |
162 __debugbreak(); | 164 __debugbreak(); |
| 165 _exit(1); |
163 } | 166 } |
164 #pragma warning(pop) | 167 #pragma warning(pop) |
165 | 168 |
166 // Handlers to silently dump the current process when there is an assert in | 169 // Handlers to silently dump the current process when there is an assert in |
167 // chrome. | 170 // chrome. |
168 void ChromeAssert(const std::string& str) { | 171 void ChromeAssert(const std::string& str) { |
169 // Get the breakpad pointer from chrome.exe | 172 // Get the breakpad pointer from chrome.exe |
170 typedef void (__cdecl *DumpProcessFunction)(); | 173 typedef void (__cdecl *DumpProcessFunction)(); |
171 DumpProcessFunction DumpProcess = reinterpret_cast<DumpProcessFunction>( | 174 DumpProcessFunction DumpProcess = reinterpret_cast<DumpProcessFunction>( |
172 ::GetProcAddress(::GetModuleHandle(chrome::kBrowserProcessExecutableName), | 175 ::GetProcAddress(::GetModuleHandle(chrome::kBrowserProcessExecutableName), |
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 | 921 |
919 int exit_code = RunNamedProcessTypeMain(process_type, main_params); | 922 int exit_code = RunNamedProcessTypeMain(process_type, main_params); |
920 | 923 |
921 if (SubprocessNeedsResourceBundle(process_type)) | 924 if (SubprocessNeedsResourceBundle(process_type)) |
922 ResourceBundle::CleanupSharedInstance(); | 925 ResourceBundle::CleanupSharedInstance(); |
923 | 926 |
924 LowLevelShutdown(); | 927 LowLevelShutdown(); |
925 | 928 |
926 return exit_code; | 929 return exit_code; |
927 } | 930 } |
OLD | NEW |