protected: void RaiseHandled() {
sigval value;
value.sival_ptr = &value; // pthread_sigqueue would guarantee the signal is delivered to this // thread, but it is a nonstandard extension and does not exist in // musl. Gtest is single threaded, and these tests don't create any // threads, so sigqueue can be used and will deliver to this thread.
sigqueue(getpid(), SIGSEGV, value);
}
// glibc doesn't implement most of these in terms of sigprocmask, which we rely on. #ifdefined(__BIONIC__)
TEST_F(SigchainTest, pthread_sigmask_setmask) {
TestSignalBlocking([]() {
sigset_t mask;
sigfillset(&mask);
ASSERT_EQ(0, pthread_sigmask(SIG_SETMASK, &mask, nullptr));
});
}
#if !defined(__riscv) // Not exposed via headers, but the symbols are available if you declare them yourself. extern"C"int sigblock(int);
TEST_F(SigchainTest, sigblock) {
TestSignalBlocking([]() { int mask = ~0U;
ASSERT_EQ(0, sigblock(mask));
});
} extern"C"int sigsetmask(int);
TEST_F(SigchainTest, sigsetmask) {
TestSignalBlocking([]() { int mask = ~0U;
ASSERT_EQ(0, sigsetmask(mask));
});
} #endif
#endif
// Make sure that we properly put ourselves back in front if we get circumvented.
TEST_F(SigchainTest, EnsureFrontOfChain) { #ifdefined(__BIONIC__)
constexpr char kLibcSoName[] = "libc.so"; #elifdefined(__GNU_LIBRARY__) && __GNU_LIBRARY__ == 6
constexpr char kLibcSoName[] = "libc.so.6"; #elifdefined(ANDROID_HOST_MUSL)
constexpr char kLibcSoName[] = "libc_musl.so"; #else #error Unknown libc #endif void* libc = dlopen(kLibcSoName, RTLD_LAZY | RTLD_NOLOAD);
ASSERT_TRUE(libc);
auto libc_sigaction = reinterpret_cast<decltype(&sigaction)>(dlsym(libc, "sigaction"));
ASSERT_TRUE(libc_sigaction);
// Our sigaction implementation always implements the "clear unknown bits" // semantics for oldact.sa_flags regardless of kernel version so we rely on it // here to test for kernel support for SA_EXPOSE_TAGBITS.
action.sa_flags = SA_SIGINFO | SA_EXPOSE_TAGBITS;
ASSERT_EQ(0, sigaction(SIGSEGV, &action, nullptr));
ASSERT_EQ(0, sigaction(SIGSEGV, nullptr, &action)); if (action.sa_flags & SA_EXPOSE_TAGBITS) {
EXPECT_EXIT(
{ [[maybe_unused]] volatileint load = *tagged_null; },
::testing::ExitedWithCode(0x2b), "");
}
} #endif
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.