summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2015-09-22 11:16:15 -0700
committerYabin Cui <yabinc@google.com>2015-09-23 16:36:20 -0700
commit01030c24b0e3ace1b4cdaf415354e2f315f4f3a9 (patch)
tree2e2783f4dd323f970e63aa2c4f1ed2181b95a09d /tests
parent829119425bcc2b5fcec8fdf219026a5192c81234 (diff)
downloadbionic-01030c24b0e3ace1b4cdaf415354e2f315f4f3a9.zip
bionic-01030c24b0e3ace1b4cdaf415354e2f315f4f3a9.tar.gz
bionic-01030c24b0e3ace1b4cdaf415354e2f315f4f3a9.tar.bz2
Increase alternative signal stack size on 64-bit devices.
Bug: 23041777 Bug: 24187462 Change-Id: I7d84c0cc775a74753a3e8e101169c0fb5dbf7437
Diffstat (limited to 'tests')
-rw-r--r--tests/pthread_test.cpp24
-rw-r--r--tests/stack_unwinding_test.cpp2
2 files changed, 25 insertions, 1 deletions
diff --git a/tests/pthread_test.cpp b/tests/pthread_test.cpp
index 8ae28d8..ad8fac6 100644
--- a/tests/pthread_test.cpp
+++ b/tests/pthread_test.cpp
@@ -27,6 +27,7 @@
#include <sys/syscall.h>
#include <time.h>
#include <unistd.h>
+#include <unwind.h>
#include <atomic>
#include <regex>
@@ -1571,3 +1572,26 @@ TEST_F(pthread_DeathTest, pthread_mutex_unlock_null_64) {
GTEST_LOG_(INFO) << "This test tests bionic implementation details on 64 bit devices.";
#endif
}
+
+extern _Unwind_Reason_Code FrameCounter(_Unwind_Context* ctx, void* arg);
+
+static volatile bool signal_handler_on_altstack_done;
+
+static void SignalHandlerOnAltStack(int signo, siginfo_t*, void*) {
+ ASSERT_EQ(SIGUSR1, signo);
+ // Check if we have enough stack space for unwinding.
+ int count = 0;
+ _Unwind_Backtrace(FrameCounter, &count);
+ ASSERT_GT(count, 0);
+ // Check if we have enough stack space for logging.
+ std::string s(2048, '*');
+ GTEST_LOG_(INFO) << s;
+ signal_handler_on_altstack_done = true;
+}
+
+TEST(pthread, big_enough_signal_stack_for_64bit_arch) {
+ signal_handler_on_altstack_done = false;
+ ScopedSignalHandler handler(SIGUSR1, SignalHandlerOnAltStack, SA_SIGINFO | SA_ONSTACK);
+ kill(getpid(), SIGUSR1);
+ ASSERT_TRUE(signal_handler_on_altstack_done);
+}
diff --git a/tests/stack_unwinding_test.cpp b/tests/stack_unwinding_test.cpp
index d1b3402..afd9e7f 100644
--- a/tests/stack_unwinding_test.cpp
+++ b/tests/stack_unwinding_test.cpp
@@ -34,7 +34,7 @@
#define noinline __attribute__((__noinline__))
#define __unused __attribute__((__unused__))
-static _Unwind_Reason_Code FrameCounter(_Unwind_Context* ctx __unused, void* arg) {
+_Unwind_Reason_Code FrameCounter(_Unwind_Context* ctx __unused, void* arg) {
int* count_ptr = reinterpret_cast<int*>(arg);
#if SHOW_FRAME_LOCATIONS