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

Side by Side Diff: client/capture_context_mac_test.cc

Issue 1298943003: asan: Bypass the “nearby PC” check (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 CaptureContext(&context_1); 95 CaptureContext(&context_1);
96 96
97 { 97 {
98 SCOPED_TRACE("context_1"); 98 SCOPED_TRACE("context_1");
99 ASSERT_NO_FATAL_FAILURE(SanityCheckContext(&context_1)); 99 ASSERT_NO_FATAL_FAILURE(SanityCheckContext(&context_1));
100 } 100 }
101 101
102 // The program counter reference value is this function’s address. The 102 // The program counter reference value is this function’s address. The
103 // captured program counter should be slightly greater than or equal to the 103 // captured program counter should be slightly greater than or equal to the
104 // reference program counter. 104 // reference program counter.
105 uintptr_t pc = ProgramCounterFromContext(&context_1);
106 #if !__has_feature(address_sanitizer)
107 // AddressSanitizer can cause enough code bloat that the “nearby” check would
108 // likely fail.
105 const uintptr_t kReferencePC = 109 const uintptr_t kReferencePC =
106 reinterpret_cast<uintptr_t>(TestCaptureContext); 110 reinterpret_cast<uintptr_t>(TestCaptureContext);
107 uintptr_t pc = ProgramCounterFromContext(&context_1);
108 EXPECT_LT(pc - kReferencePC, 64u); 111 EXPECT_LT(pc - kReferencePC, 64u);
112 #endif
109 113
110 // Declare sp and context_2 here because all local variables need to be 114 // Declare sp and context_2 here because all local variables need to be
111 // declared before computing the stack pointer reference value, so that the 115 // declared before computing the stack pointer reference value, so that the
112 // reference value can be the lowest value possible. 116 // reference value can be the lowest value possible.
113 uintptr_t sp; 117 uintptr_t sp;
114 NativeCPUContext context_2; 118 NativeCPUContext context_2;
115 119
116 // The stack pointer reference value is the lowest address of a local variable 120 // The stack pointer reference value is the lowest address of a local variable
117 // in this function. The captured program counter will be slightly less than 121 // in this function. The captured program counter will be slightly less than
118 // or equal to the reference stack pointer. 122 // or equal to the reference stack pointer.
(...skipping 20 matching lines...) Expand all
139 EXPECT_GT(ProgramCounterFromContext(&context_2), pc); 143 EXPECT_GT(ProgramCounterFromContext(&context_2), pc);
140 } 144 }
141 145
142 TEST(CaptureContextMac, CaptureContext) { 146 TEST(CaptureContextMac, CaptureContext) {
143 ASSERT_NO_FATAL_FAILURE(TestCaptureContext()); 147 ASSERT_NO_FATAL_FAILURE(TestCaptureContext());
144 } 148 }
145 149
146 } // namespace 150 } // namespace
147 } // namespace test 151 } // namespace test
148 } // namespace crashpad 152 } // namespace crashpad
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698