diff options
author | Josh Gao <jmgao@google.com> | 2018-10-08 17:28:07 -0700 |
---|---|---|
committer | Josh Gao <jmgao@google.com> | 2018-10-09 16:27:22 -0700 |
commit | baf20fc9122740ff2baa34d28001e8bdfac9568c (patch) | |
tree | 8e6f717de9cef90828010497ef80ab454c0eb4c6 /tests/spawn_test.cpp | |
parent | 773c697f815d43182adf1eb430f4899255088d6b (diff) |
Block TIMER_SIGNAL in sigprocmask(SIG_SETMASK, ...).
Previously, we were zeroing out the reserved signals, when we actually
wanted to have TIMER_SIGNAL always be blocked, and the other signals
always be unblocked. This resulted in process termination when a
SIGEV_THREAD timer callback calls sigprocmask(SIG_SETMASK, ...) with
any signal mask value, and then subsequently fails to complete its
callback and reach the sigtimedwait in bionic before the next timer
iteration triggers.
Add a how argument to filter_reserved_signals to appropriately
block/unblock our reserved signals.
Bug: http://b/116783733
Test: bionic-unit-tests32/64
Change-Id: Ie5339682cdeb914711cd4089cd26ee395704d0df
Diffstat (limited to 'tests/spawn_test.cpp')
-rw-r--r-- | tests/spawn_test.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/tests/spawn_test.cpp b/tests/spawn_test.cpp index a5e7e56f3..04b66d398 100644 --- a/tests/spawn_test.cpp +++ b/tests/spawn_test.cpp @@ -396,7 +396,13 @@ TEST(spawn, posix_spawn_POSIX_SPAWN_SETSIGMASK) { // Check that's what happens... ProcStatus ps = {}; GetChildStatus(&sa, &ps); - EXPECT_EQ(static_cast<uint64_t>(1 << (SIGALRM - 1)), ps.sigblk); + + // TIMER_SIGNAL should also be blocked. + uint64_t expected_blocked = 0; + SignalSetAdd(&expected_blocked, SIGALRM); + SignalSetAdd(&expected_blocked, __SIGRTMIN + 0); + EXPECT_EQ(expected_blocked, ps.sigblk); + EXPECT_EQ(static_cast<uint64_t>(0), ps.sigign); ASSERT_EQ(0, posix_spawnattr_destroy(&sa)); @@ -421,8 +427,15 @@ TEST(spawn, posix_spawn_POSIX_SPAWN_SETSIGDEF) { // Check that's what happens... ProcStatus ps = {}; GetChildStatus(&sa, &ps); - EXPECT_EQ(static_cast<uint64_t>(0), ps.sigblk); - EXPECT_EQ(static_cast<uint64_t>(1 << (SIGCONT - 1)), ps.sigign); + + // TIMER_SIGNAL should be blocked. + uint64_t expected_blocked = 0; + SignalSetAdd(&expected_blocked, __SIGRTMIN + 0); + EXPECT_EQ(expected_blocked, ps.sigblk); + + uint64_t expected_ignored = 0; + SignalSetAdd(&expected_ignored, SIGCONT); + EXPECT_EQ(expected_ignored, ps.sigign); ASSERT_EQ(0, posix_spawnattr_destroy(&sa)); } |