diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2021-06-10 08:26:13 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2021-06-10 08:26:13 +0000 |
commit | 78a0067dcb2df8bd295428bb1870fc132ee273b0 (patch) | |
tree | cdd69b84cc2f793888992f8fb76440dc2db17c72 | |
parent | d74c5cdcdedeb5e8fc4ea3454d0fdec393349bb4 (diff) | |
parent | 07a37c4ba75e5c0317422583254e743d3404ec4c (diff) | |
download | bionic-78a0067dcb2df8bd295428bb1870fc132ee273b0.tar.gz |
Snap for 7445263 from 07a37c4ba75e5c0317422583254e743d3404ec4c to sc-d2-release
Change-Id: I21ae4191ce7afbc167eb1b15cccc6d6241f35fad
-rw-r--r-- | libc/bionic/pthread_create.cpp | 5 | ||||
-rw-r--r-- | tests/dl_test.cpp | 15 | ||||
-rw-r--r-- | tests/stack_unwinding_test.cpp | 23 |
3 files changed, 33 insertions, 10 deletions
diff --git a/libc/bionic/pthread_create.cpp b/libc/bionic/pthread_create.cpp index 46d9e8672..121b26f82 100644 --- a/libc/bionic/pthread_create.cpp +++ b/libc/bionic/pthread_create.cpp @@ -331,6 +331,11 @@ void __set_stack_and_tls_vma_name(bool is_main_thread) { extern "C" int __rt_sigprocmask(int, const sigset64_t*, sigset64_t*, size_t); __attribute__((no_sanitize("hwaddress"))) +#ifdef __aarch64__ +// This function doesn't return, but it does appear in stack traces. Avoid using return PAC in this +// function because we may end up resetting IA, which may confuse unwinders due to mismatching keys. +__attribute__((target("branch-protection=bti"))) +#endif static int __pthread_start(void* arg) { pthread_internal_t* thread = reinterpret_cast<pthread_internal_t*>(arg); diff --git a/tests/dl_test.cpp b/tests/dl_test.cpp index 766f27a0b..47bf13374 100644 --- a/tests/dl_test.cpp +++ b/tests/dl_test.cpp @@ -264,8 +264,11 @@ static void create_ld_config_file(const char* config_file) { #endif #if defined(__BIONIC__) -static bool is_debuggable_build() { - return android::base::GetBoolProperty("ro.debuggable", false); +// This test can't rely on ro.debuggable, because it might have been forced on +// in a user build ("Force Debuggable"). In that configuration, ro.debuggable is +// true, but Bionic's LD_CONFIG_FILE testing support is still disabled. +static bool is_user_build() { + return android::base::GetProperty("ro.build.type", "user") == std::string("user"); } #endif @@ -282,7 +285,7 @@ static bool is_debuggable_build() { TEST(dl, exec_with_ld_config_file) { #if defined(__BIONIC__) SKIP_WITH_HWASAN << "libclang_rt.hwasan is not found with custom ld config"; - if (!is_debuggable_build()) { + if (is_user_build()) { GTEST_SKIP() << "LD_CONFIG_FILE is not supported on user build"; } std::string helper = GetTestlibRoot() + @@ -319,7 +322,7 @@ TEST(dl, exec_with_ld_config_file) { TEST(dl, exec_with_ld_config_file_with_ld_preload) { #if defined(__BIONIC__) SKIP_WITH_HWASAN << "libclang_rt.hwasan is not found with custom ld config"; - if (!is_debuggable_build()) { + if (is_user_build()) { GTEST_SKIP() << "LD_CONFIG_FILE is not supported on user build"; } std::string helper = GetTestlibRoot() + @@ -356,8 +359,8 @@ TEST(dl, disable_ld_config_file) { // This test is only for CTS. GTEST_SKIP() << "test is not supported with root uid"; } - if (is_debuggable_build()) { - GTEST_SKIP() << "test is not supported on debuggable build"; + if (!is_user_build()) { + GTEST_SKIP() << "test requires user build"; } std::string error_message = std::string("CANNOT LINK EXECUTABLE ") + diff --git a/tests/stack_unwinding_test.cpp b/tests/stack_unwinding_test.cpp index 0ff6f30a6..2f891a6e1 100644 --- a/tests/stack_unwinding_test.cpp +++ b/tests/stack_unwinding_test.cpp @@ -66,13 +66,28 @@ static int noinline unwind_one_frame_deeper() { return count; } -TEST(stack_unwinding, easy) { +static void UnwindTest() { int count = 0; _Unwind_Backtrace(FrameCounter, &count); int deeper_count = unwind_one_frame_deeper(); ASSERT_EQ(count + 1, deeper_count); } +TEST(stack_unwinding, easy) { + UnwindTest(); +} + +TEST(stack_unwinding, thread) { + pthread_t thread; + ASSERT_EQ(0, pthread_create(&thread, nullptr, [](void*) -> void* { + UnwindTest(); + return nullptr; + }, nullptr)); + void *retval; + ASSERT_EQ(0, pthread_join(thread, &retval)); + EXPECT_EQ(nullptr, retval); +} + struct UnwindData { volatile bool signal_handler_complete = false; int expected_frame_count = 0; @@ -98,7 +113,7 @@ static void verify_unwind_data(const UnwindData& unwind_data) { EXPECT_EQ(unwind_data.handler_frame_count + 1, unwind_data.handler_one_deeper_frame_count); } -static void noinline UnwindTest() { +static void noinline SignalUnwindTest() { g_unwind_data = {}; _Unwind_Backtrace(FrameCounter, &g_unwind_data.expected_frame_count); @@ -114,12 +129,12 @@ static void noinline UnwindTest() { TEST(stack_unwinding, unwind_through_signal_frame) { ScopedSignalHandler ssh(SIGUSR1, UnwindSignalHandler); - UnwindTest(); + SignalUnwindTest(); } // On LP32, the SA_SIGINFO flag gets you __restore_rt instead of __restore. TEST(stack_unwinding, unwind_through_signal_frame_SA_SIGINFO) { ScopedSignalHandler ssh(SIGUSR1, UnwindSignalHandler, SA_SIGINFO); - UnwindTest(); + SignalUnwindTest(); } |