| OLD | NEW |
| 1 // Copyright 2012 Google Inc. All Rights Reserved. | 1 // Copyright 2012 Google Inc. All Rights Reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 if (!SetUpMemoryNotifier()) | 494 if (!SetUpMemoryNotifier()) |
| 495 return false; | 495 return false; |
| 496 if (!SetUpLogger()) | 496 if (!SetUpLogger()) |
| 497 return false; | 497 return false; |
| 498 if (!SetUpStackCache()) | 498 if (!SetUpStackCache()) |
| 499 return false; | 499 return false; |
| 500 if (!SetUpHeapManager()) | 500 if (!SetUpHeapManager()) |
| 501 return false; | 501 return false; |
| 502 WindowsHeapAdapter::SetUp(heap_manager_.get()); | 502 WindowsHeapAdapter::SetUp(heap_manager_.get()); |
| 503 | 503 |
| 504 // Determine the preferred crash reporter type, as specified in the | |
| 505 // environment. If this isn't present it defaults to | |
| 506 // kDefaultCrashReporterType, in which case experiments or command-line flags | |
| 507 // may specify the crash reporter to use. | |
| 508 CrashReporterType crash_reporter_type = | |
| 509 GetCrashReporterTypeFromEnvironment(logger()); | |
| 510 | |
| 511 if (params_.feature_randomization) { | 504 if (params_.feature_randomization) { |
| 512 AsanFeatureSet feature_set = GenerateRandomFeatureSet(); | 505 AsanFeatureSet feature_set = GenerateRandomFeatureSet(); |
| 513 PropagateFeatureSet(feature_set); | 506 PropagateFeatureSet(feature_set); |
| 514 } | 507 } |
| 515 | 508 |
| 516 // Propagates the flags values to the different modules. | 509 // Propagates the flags values to the different modules. |
| 517 PropagateParams(); | 510 PropagateParams(); |
| 518 | 511 |
| 519 // The name 'disable_breakpad_reporting' is legacy; this actually means to | 512 InitializeCrashReporter(); |
| 520 // disable all external crash reporting integration. | |
| 521 if (!params_.disable_breakpad_reporting) { | |
| 522 // This will create the crash reporter with a preference for creating a | |
| 523 // reporter of the hinted type. If such a reporter isn't available, it will | |
| 524 // fall back to trying to create the most 'modern' reporter available. | |
| 525 crash_reporter_.reset(CreateCrashReporterWithTypeHint( | |
| 526 logger(), crash_reporter_type).release()); | |
| 527 } | |
| 528 | |
| 529 // Set up the appropriate error handler depending on whether or not | |
| 530 // we successfully initialized a crash reporter. | |
| 531 if (crash_reporter_.get() != nullptr) { | |
| 532 logger_->Write(base::StringPrintf( | |
| 533 "SyzyASAN: Using %s for error reporting.", | |
| 534 crash_reporter_->GetName())); | |
| 535 SetErrorCallBack(base::Bind(&CrashReporterErrorHandler)); | |
| 536 } else { | |
| 537 logger_->Write("SyzyASAN: Using default error reporting handler."); | |
| 538 SetErrorCallBack(base::Bind(&DefaultErrorHandler)); | |
| 539 } | |
| 540 | 513 |
| 541 // Install the unhandled exception handler. This is only installed once | 514 // Install the unhandled exception handler. This is only installed once |
| 542 // across all runtime instances in a process so we check that it hasn't | 515 // across all runtime instances in a process so we check that it hasn't |
| 543 // already been installed. | 516 // already been installed. |
| 544 // TODO(chrisha): Conditionally install this based on the crash reporter in | 517 // TODO(chrisha): Conditionally install this based on the crash reporter in |
| 545 // use. Eventually, Crashpad will provide us a callback instead of having us | 518 // use. Eventually, Crashpad will provide us a callback instead of having us |
| 546 // register the handler ourselves. | 519 // register the handler ourselves. |
| 547 if (!uef_installed_) { | 520 if (!uef_installed_) { |
| 548 uef_installed_ = true; | 521 uef_installed_ = true; |
| 549 previous_uef_ = ::SetUnhandledExceptionFilter(&UnhandledExceptionFilter); | 522 previous_uef_ = ::SetUnhandledExceptionFilter(&UnhandledExceptionFilter); |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1220 AsanFeatureSet AsanRuntime::GetEnabledFeatureSet() { | 1193 AsanFeatureSet AsanRuntime::GetEnabledFeatureSet() { |
| 1221 AsanFeatureSet enabled_features = static_cast<AsanFeatureSet>(0U); | 1194 AsanFeatureSet enabled_features = static_cast<AsanFeatureSet>(0U); |
| 1222 if (heap_manager_->enable_page_protections_) | 1195 if (heap_manager_->enable_page_protections_) |
| 1223 enabled_features |= ASAN_FEATURE_ENABLE_PAGE_PROTECTIONS; | 1196 enabled_features |= ASAN_FEATURE_ENABLE_PAGE_PROTECTIONS; |
| 1224 if (params_.enable_large_block_heap) | 1197 if (params_.enable_large_block_heap) |
| 1225 enabled_features |= ASAN_FEATURE_ENABLE_LARGE_BLOCK_HEAP; | 1198 enabled_features |= ASAN_FEATURE_ENABLE_LARGE_BLOCK_HEAP; |
| 1226 | 1199 |
| 1227 return enabled_features; | 1200 return enabled_features; |
| 1228 } | 1201 } |
| 1229 | 1202 |
| 1203 void AsanRuntime::InitializeCrashReporter() { |
| 1204 if (crash_reporter_.get() != nullptr) { |
| 1205 logger_->Write(base::StringPrintf( |
| 1206 "SyzyASAN: Reinitializing crash reporter.", |
| 1207 crash_reporter_->GetName())); |
| 1208 } |
| 1209 |
| 1210 // Determine the preferred crash reporter type, as specified in the |
| 1211 // environment. If this isn't present it defaults to |
| 1212 // kDefaultCrashReporterType, in which case experiments or command-line flags |
| 1213 // may specify the crash reporter to use. |
| 1214 CrashReporterType crash_reporter_type = |
| 1215 GetCrashReporterTypeFromEnvironment(logger()); |
| 1216 |
| 1217 // The name 'disable_breakpad_reporting' is legacy; this actually means to |
| 1218 // disable all external crash reporting integration. |
| 1219 if (!params_.disable_breakpad_reporting) { |
| 1220 // This will create the crash reporter with a preference for creating a |
| 1221 // reporter of the hinted type. If such a reporter isn't available, it will |
| 1222 // fall back to trying to create the most 'modern' reporter available. |
| 1223 crash_reporter_.reset(CreateCrashReporterWithTypeHint( |
| 1224 logger(), crash_reporter_type).release()); |
| 1225 } |
| 1226 |
| 1227 // Set up the appropriate error handler depending on whether or not |
| 1228 // we successfully initialized a crash reporter. |
| 1229 if (crash_reporter_.get() != nullptr) { |
| 1230 logger_->Write(base::StringPrintf( |
| 1231 "SyzyASAN: Using %s for error reporting.", |
| 1232 crash_reporter_->GetName())); |
| 1233 SetErrorCallBack(base::Bind(&CrashReporterErrorHandler)); |
| 1234 } else { |
| 1235 logger_->Write("SyzyASAN: Using default error reporting handler."); |
| 1236 SetErrorCallBack(base::Bind(&DefaultErrorHandler)); |
| 1237 } |
| 1238 } |
| 1239 |
| 1230 } // namespace asan | 1240 } // namespace asan |
| 1231 } // namespace agent | 1241 } // namespace agent |
| OLD | NEW |