Merge "dynamic libc: ignore ART profiling signal by default."
This commit is contained in:
commit
e7221986c8
3 changed files with 28 additions and 5 deletions
|
@ -63,6 +63,14 @@ __LIBC_HIDDEN__ void __libc_init_profiling_handlers() {
|
|||
action.sa_flags = SA_SIGINFO | SA_RESTART;
|
||||
action.sa_sigaction = HandleProfilingSignal;
|
||||
sigaction(BIONIC_SIGNAL_PROFILER, &action, nullptr);
|
||||
|
||||
// The perfetto_hprof ART plugin installs a signal handler to handle this signal. That plugin
|
||||
// does not get loaded for a) non-apps, b) non-profilable apps on user. The default signal
|
||||
// disposition is to crash. We do not want the target to crash if we accidentally target a
|
||||
// non-app or non-profilable process.
|
||||
//
|
||||
// This does *not* get run for processes that statically link libc, and those will still crash.
|
||||
signal(BIONIC_SIGNAL_ART_PROFILER, SIG_IGN);
|
||||
}
|
||||
|
||||
static void HandleSigsysSeccompOverride(int, siginfo_t*, void*);
|
||||
|
|
|
@ -47,8 +47,10 @@
|
|||
// If you change this, also change __ndk_legacy___libc_current_sigrtmin
|
||||
// in <android/legacy_signal_inlines.h> to match.
|
||||
|
||||
#define BIONIC_SIGNAL_POSIX_TIMERS (__SIGRTMIN + 0)
|
||||
#define BIONIC_SIGNAL_DEBUGGER (__SIGRTMIN + 3)
|
||||
#define BIONIC_SIGNAL_PROFILER (__SIGRTMIN + 4)
|
||||
#define BIONIC_SIGNAL_ART_PROFILER (__SIGRTMIN + 6)
|
||||
#define BIONIC_SIGNAL_FDTRACK (__SIGRTMIN + 7)
|
||||
|
||||
#define __SIGRT_RESERVED 8
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue