| 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 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 // Call the callback to handle this error. | 623 // Call the callback to handle this error. |
| 624 DCHECK(!asan_error_callback_.is_null()); | 624 DCHECK(!asan_error_callback_.is_null()); |
| 625 asan_error_callback_.Run(error_info); | 625 asan_error_callback_.Run(error_info); |
| 626 } | 626 } |
| 627 | 627 |
| 628 void AsanRuntime::SetErrorCallBack(const AsanOnErrorCallBack& callback) { | 628 void AsanRuntime::SetErrorCallBack(const AsanOnErrorCallBack& callback) { |
| 629 asan_error_callback_ = callback; | 629 asan_error_callback_ = callback; |
| 630 } | 630 } |
| 631 | 631 |
| 632 bool AsanRuntime::SetUpShadow() { | 632 bool AsanRuntime::SetUpShadow() { |
| 633 // If a non-trivial static shadow is provided, but it's the wrong size, then | 633 // Dynamically allocate the shadow memory. |
| 634 // this runtime is unable to support hotpatching and its being run in the | 634 shadow_.reset(new Shadow()); |
| 635 // wrong memory model. | |
| 636 if (asan_memory_interceptors_shadow_memory_size > 1 && | |
| 637 asan_memory_interceptors_shadow_memory_size != Shadow::RequiredLength()) { | |
| 638 static const char kMessage[] = | |
| 639 "Runtime can't support the current memory model. LAA?"; | |
| 640 LaunchMessageBox(kMessage); | |
| 641 NOTREACHED() << kMessage; | |
| 642 } | |
| 643 | 635 |
| 644 // Use the static shadow memory if possible. | 636 // If the allocation fails, then return false. |
| 645 if (asan_memory_interceptors_shadow_memory_size == Shadow::RequiredLength()) { | 637 if (shadow_->shadow() == nullptr) |
| 646 shadow_.reset(new Shadow(asan_memory_interceptors_shadow_memory, | 638 return false; |
| 647 asan_memory_interceptors_shadow_memory_size)); | |
| 648 } else { | |
| 649 // Otherwise dynamically allocate the shadow memory. | |
| 650 shadow_.reset(new Shadow()); | |
| 651 | |
| 652 // If the allocation fails, then return false. | |
| 653 if (shadow_->shadow() == nullptr) | |
| 654 return false; | |
| 655 | 639 |
| 656 #ifndef _WIN64 | 640 #ifndef _WIN64 |
| 657 // Patch the memory interceptors to refer to the newly allocated shadow. | 641 // Patch the memory interceptors to refer to the newly allocated shadow. |
| 658 // If this fails simply explode because it is unsafe to continue. | 642 // If this fails simply explode because it is unsafe to continue. |
| 659 CHECK(PatchMemoryInterceptorShadowReferences( | 643 CHECK(PatchMemoryInterceptorShadowReferences( |
| 660 asan_memory_interceptors_shadow_memory, shadow_->shadow())); | 644 asan_memory_interceptors_shadow_memory, shadow_->shadow())); |
| 661 #endif | 645 #endif |
| 662 } | |
| 663 | 646 |
| 664 // Setup the shadow and configure the various interceptors to use it. | 647 // Setup the shadow and configure the various interceptors to use it. |
| 665 shadow_->SetUp(); | 648 shadow_->SetUp(); |
| 666 agent::asan::SetCrtInterceptorShadow(shadow_.get()); | 649 agent::asan::SetCrtInterceptorShadow(shadow_.get()); |
| 667 agent::asan::SetMemoryInterceptorShadow(shadow_.get()); | 650 agent::asan::SetMemoryInterceptorShadow(shadow_.get()); |
| 668 agent::asan::SetSystemInterceptorShadow(shadow_.get()); | 651 agent::asan::SetSystemInterceptorShadow(shadow_.get()); |
| 669 | 652 |
| 670 return true; | 653 return true; |
| 671 } | 654 } |
| 672 | 655 |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1239 if (heap_manager_->enable_page_protections_) | 1222 if (heap_manager_->enable_page_protections_) |
| 1240 enabled_features |= ASAN_FEATURE_ENABLE_PAGE_PROTECTIONS; | 1223 enabled_features |= ASAN_FEATURE_ENABLE_PAGE_PROTECTIONS; |
| 1241 if (params_.enable_large_block_heap) | 1224 if (params_.enable_large_block_heap) |
| 1242 enabled_features |= ASAN_FEATURE_ENABLE_LARGE_BLOCK_HEAP; | 1225 enabled_features |= ASAN_FEATURE_ENABLE_LARGE_BLOCK_HEAP; |
| 1243 | 1226 |
| 1244 return enabled_features; | 1227 return enabled_features; |
| 1245 } | 1228 } |
| 1246 | 1229 |
| 1247 } // namespace asan | 1230 } // namespace asan |
| 1248 } // namespace agent | 1231 } // namespace agent |
| OLD | NEW |