diff options
author | 2022-11-01 12:21:29 +0000 | |
---|---|---|
committer | 2022-11-07 08:35:21 +0000 | |
commit | 18a41f0ae2368a83b8febafc13f53d106755fe9b (patch) | |
tree | 449af883ea5002f40e1e3083d0d68423ea50e8f0 /compiler/exception_test.cc | |
parent | d8a521948115649720f3098386a5775d279e6274 (diff) |
Fix ExceptionTest to properly untag when setting up a fake stack
ExceptionTest.StackTraceElement sets up a fake stack to test stack
walking. When setting up this stack, the return pc is obtained from
ToNativeQuickPc which returns HWAsan tagged pointers. We don't expect
tagged values on stack so untag before setting it as return pc.
Bug: 230392320
Test: gtest.py --gtest_filter=ExceptionTest.StackTrace (on hwasan)
Change-Id: Ic4783e37b4d5d46fbe5c3817eb094a04d97fd565
Diffstat (limited to 'compiler/exception_test.cc')
-rw-r--r-- | compiler/exception_test.cc | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/compiler/exception_test.cc b/compiler/exception_test.cc index 9a3a2bafc9..66045223b0 100644 --- a/compiler/exception_test.cc +++ b/compiler/exception_test.cc @@ -170,7 +170,6 @@ TEST_F(ExceptionTest, FindCatchHandler) { } TEST_F(ExceptionTest, StackTraceElement) { - SKIP_WITH_HWASAN; // TODO(b/230392320): re-enable with HWASan once fixed. Thread* thread = Thread::Current(); thread->TransitionFromSuspendedToRunnable(); bool started = runtime_->Start(); @@ -197,13 +196,22 @@ TEST_F(ExceptionTest, StackTraceElement) { OatQuickMethodHeader* header = OatQuickMethodHeader::FromEntryPoint( method_g_->GetEntryPointFromQuickCompiledCode()); - fake_stack.push_back(header->ToNativeQuickPc(method_g_, kDexPc)); // return pc + // Untag native pc when running with hwasan since the pcs on the stack aren't tagged and we use + // this to create a fake stack. See OatQuickMethodHeader::Contains where we untag code pointers + // before comparing it with the PC from the stack. + uintptr_t native_pc = header->ToNativeQuickPc(method_g_, kDexPc); + if (running_with_hwasan()) { + // TODO(228989263): Use HWASanUntag once we have a hwasan target for tests too. HWASanUntag + // uses static checks which won't work if we don't have a dedicated target. + native_pc = (native_pc & ((1ULL << 56) - 1)); + } + fake_stack.push_back(native_pc); // return pc // Create/push fake 16byte stack frame for method g fake_stack.push_back(reinterpret_cast<uintptr_t>(method_g_)); fake_stack.push_back(0); fake_stack.push_back(0); - fake_stack.push_back(header->ToNativeQuickPc(method_g_, kDexPc)); // return pc + fake_stack.push_back(native_pc); // return pc. // Create/push fake 16byte stack frame for method f fake_stack.push_back(reinterpret_cast<uintptr_t>(method_f_)); |