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

Unified Diff: chrome/installer/setup/setup_main.cc

Issue 2559053002: Instrument setup.exe in the SyzyAsan builds.
Patch Set: Rebase Created 3 years, 9 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 | « chrome/installer/setup/setup_constants.cc ('k') | chrome/tools/build/win/create_installer_archive.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/setup/setup_main.cc
diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc
index b8d66b6b4d596eb278d0ee5245f344064b7ba2fe..1fc6037ba83630f601a9aacd9094cf98bb0574b2 100644
--- a/chrome/installer/setup/setup_main.cc
+++ b/chrome/installer/setup/setup_main.cc
@@ -16,6 +16,7 @@
#include "base/at_exit.h"
#include "base/command_line.h"
+#include "base/debug/asan_invalid_access.h"
grt (UTC plus 2) 2017/03/10 07:57:36 nit: put this in a #if defined(SYZYASAN) block aft
Sébastien Marchand 2017/04/05 21:07:02 Done.
#include "base/file_version_info.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
@@ -1042,6 +1043,21 @@ bool HandleNonInstallCmdLineOptions(const base::FilePath& setup_exe,
cmd_line.GetSwitchValueNative(
installer::switches::kSetDisplayVersionValue));
*exit_code = OverwriteDisplayVersions(registry_product, registry_value);
+#if defined(SYZYASAN)
+ } else if (cmd_line.HasSwitch(installer::switches::kInduceAsanCrash)) {
+ std::string crash_type =
+ cmd_line.GetSwitchValueASCII(installer::switches::kInduceAsanCrash);
+ if (crash_type == installer::switches::kAsanUseAfterFree) {
+ base::debug::AsanHeapUseAfterFree();
+ } else if (crash_type == installer::switches::kAsanHeapOverflow) {
+ base::debug::AsanHeapOverflow();
+ } else if (crash_type == installer::switches::kAsanHeapUnderflow) {
+ base::debug::AsanHeapUnderflow();
+ } else {
+ LOG(ERROR) << "Invalid Asan error type: " << crash_type;
+ handled = false;
+ }
+#endif
} else {
handled = false;
}
@@ -1049,6 +1065,25 @@ bool HandleNonInstallCmdLineOptions(const base::FilePath& setup_exe,
return handled;
}
+#if defined(SYZYASAN)
+// Initialize the SyzyAsan crash reporter. This should only be called once the
+// crash reporter has been initialized. There should be only one call to this
+// function.
+void SetupSyzyAsan() {
+ typedef VOID(WINAPI * SyzyAsanInitializeCrashReporterFn)();
grt (UTC plus 2) 2017/03/10 07:57:36 nit: prefer "using" over "typedef"
Sébastien Marchand 2017/04/05 21:07:02 Done.
+ HMODULE syzyasan_handle = ::GetModuleHandle(L"syzyasan_rtl.dll");
+ if (!syzyasan_handle)
+ return;
+
+ SyzyAsanInitializeCrashReporterFn syzyasan_init_crash_reporter =
+ reinterpret_cast<SyzyAsanInitializeCrashReporterFn>(
+ ::GetProcAddress(syzyasan_handle, "asan_InitializeCrashReporter"));
+ if (syzyasan_init_crash_reporter) {
grt (UTC plus 2) 2017/03/10 07:57:36 nit: omit braces for one-liner
Sébastien Marchand 2017/04/05 21:07:02 Done.
+ syzyasan_init_crash_reporter();
+ }
+}
+#endif
+
} // namespace
namespace installer {
@@ -1364,6 +1399,10 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
installer::SetInitialCrashKeys(installer_state);
installer::SetCrashKeysFromCommandLine(cmd_line);
+#if defined(SYZYASAN)
+ SetupSyzyAsan();
+#endif
+
// Make sure the process exits cleanly on unexpected errors.
base::EnableTerminationOnHeapCorruption();
base::EnableTerminationOnOutOfMemory();
« no previous file with comments | « chrome/installer/setup/setup_constants.cc ('k') | chrome/tools/build/win/create_installer_archive.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698