summaryrefslogtreecommitdiff
path: root/tests/spawn_test.cpp
diff options
context:
space:
mode:
authorFlorian Mayer <fmayer@google.com>2020-03-24 15:59:27 +0100
committerFlorian Mayer <fmayer@google.com>2020-03-30 10:17:45 +0100
commit5e0d80b3ec5414d0fb7ce195c29abfbae5b2ded6 (patch)
treeaa734dbbac78f3abf375849e10408d3eee9e9f33 /tests/spawn_test.cpp
parenta08c97bee6523a46a44c69074c0af8a7bf980867 (diff)
dynamic libc: ignore ART profiling signal by default.
These solves the issue that targetting non-profilable apps crashed them. There is still a race condition between starting the app and the SIG_IGN being installed, but that will be fixed in follow-ups. This also does not cover programs that statically link libc, but those are rare. This might be reverted if we find a more general solution to b/151835887. Bug: 151328035 Test: java profile sysui, doesn't crash Test: atest CtsBionicTestCases This is a cherry-pick of 96272df35cbc89c696dcacc0796519a89d9e2212 Change-Id: I6b99352ed50afe15a609f7ddb85312c2676ddf11 Merged-In: I6b99352ed50afe15a609f7ddb85312c2676ddf11
Diffstat (limited to 'tests/spawn_test.cpp')
-rw-r--r--tests/spawn_test.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/tests/spawn_test.cpp b/tests/spawn_test.cpp
index 04b66d398..d7ed970ec 100644
--- a/tests/spawn_test.cpp
+++ b/tests/spawn_test.cpp
@@ -31,6 +31,8 @@
# if !defined(POSIX_SPAWN_SETSID)
# define POSIX_SPAWN_SETSID 0
# endif
+#else
+#include <platform/bionic/reserved_signals.h>
#endif
TEST(spawn, posix_spawnattr_init_posix_spawnattr_destroy) {
@@ -292,7 +294,7 @@ struct ProcStat {
pid_t sid;
};
-static void GetChildStat(posix_spawnattr_t* sa, ProcStat* ps) {
+static __attribute__((unused)) void GetChildStat(posix_spawnattr_t* sa, ProcStat* ps) {
std::string content;
CatFileToString(sa, "/proc/self/stat", &content);
@@ -307,7 +309,7 @@ struct ProcStatus {
uint64_t sigign;
};
-static void GetChildStatus(posix_spawnattr_t* sa, ProcStatus* ps) {
+static void __attribute__((unused)) GetChildStatus(posix_spawnattr_t* sa, ProcStatus* ps) {
std::string content;
CatFileToString(sa, "/proc/self/status", &content);
@@ -377,6 +379,9 @@ TEST(spawn, posix_spawn_POSIX_SPAWN_SETPGROUP_set) {
}
TEST(spawn, posix_spawn_POSIX_SPAWN_SETSIGMASK) {
+#if defined(__GLIBC__)
+ GTEST_SKIP() << "glibc doesn't ignore the same signals.";
+#else
// Block SIGBUS in the parent...
sigset_t just_SIGBUS;
sigemptyset(&just_SIGBUS);
@@ -400,15 +405,21 @@ TEST(spawn, posix_spawn_POSIX_SPAWN_SETSIGMASK) {
// TIMER_SIGNAL should also be blocked.
uint64_t expected_blocked = 0;
SignalSetAdd(&expected_blocked, SIGALRM);
- SignalSetAdd(&expected_blocked, __SIGRTMIN + 0);
+ SignalSetAdd(&expected_blocked, BIONIC_SIGNAL_POSIX_TIMERS);
EXPECT_EQ(expected_blocked, ps.sigblk);
- EXPECT_EQ(static_cast<uint64_t>(0), ps.sigign);
+ uint64_t expected_ignored = 0;
+ SignalSetAdd(&expected_ignored, BIONIC_SIGNAL_ART_PROFILER);
+ EXPECT_EQ(expected_ignored, ps.sigign);
ASSERT_EQ(0, posix_spawnattr_destroy(&sa));
+#endif
}
TEST(spawn, posix_spawn_POSIX_SPAWN_SETSIGDEF) {
+#if defined(__GLIBC__)
+ GTEST_SKIP() << "glibc doesn't ignore the same signals.";
+#else
// Ignore SIGALRM and SIGCONT in the parent...
ASSERT_NE(SIG_ERR, signal(SIGALRM, SIG_IGN));
ASSERT_NE(SIG_ERR, signal(SIGCONT, SIG_IGN));
@@ -430,14 +441,16 @@ TEST(spawn, posix_spawn_POSIX_SPAWN_SETSIGDEF) {
// TIMER_SIGNAL should be blocked.
uint64_t expected_blocked = 0;
- SignalSetAdd(&expected_blocked, __SIGRTMIN + 0);
+ SignalSetAdd(&expected_blocked, BIONIC_SIGNAL_POSIX_TIMERS);
EXPECT_EQ(expected_blocked, ps.sigblk);
uint64_t expected_ignored = 0;
SignalSetAdd(&expected_ignored, SIGCONT);
+ SignalSetAdd(&expected_ignored, BIONIC_SIGNAL_ART_PROFILER);
EXPECT_EQ(expected_ignored, ps.sigign);
ASSERT_EQ(0, posix_spawnattr_destroy(&sa));
+#endif
}
TEST(spawn, signal_stress) {