Skip to content

Revert "[compiler-rt] Also consider SIGPROF as a synchronous signal" #86416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ const int SIGFPE = 8;
const int SIGSEGV = 11;
const int SIGPIPE = 13;
const int SIGTERM = 15;
const int SIGPROF = 27;
#if defined(__mips__) || SANITIZER_FREEBSD || SANITIZER_APPLE || SANITIZER_NETBSD
const int SIGBUS = 10;
const int SIGSYS = 12;
Expand Down Expand Up @@ -2180,8 +2179,7 @@ void sighandler(int sig, __sanitizer_siginfo *info, void *ctx) {
return;
}
// Don't mess with synchronous signals.
const bool sync = is_sync_signal(sctx, sig, info) ||
(sig == SIGPROF && thr->is_inited && !thr->is_dead);
const bool sync = is_sync_signal(sctx, sig, info);
if (sync ||
// If we are in blocking function, we can safely process it now
// (but check if we are in a recursive interceptor,
Expand Down
6 changes: 3 additions & 3 deletions compiler-rt/test/tsan/signal_errno.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static void MyHandler(int, siginfo_t *s, void *c) {

static void* sendsignal(void *p) {
barrier_wait(&barrier);
pthread_kill(mainth, SIGALRM);
pthread_kill(mainth, SIGPROF);
return 0;
}

Expand All @@ -37,7 +37,7 @@ int main() {
mainth = pthread_self();
struct sigaction act = {};
act.sa_sigaction = &MyHandler;
sigaction(SIGALRM, &act, 0);
sigaction(SIGPROF, &act, 0);
pthread_t th;
pthread_create(&th, 0, sendsignal, 0);
loop();
Expand All @@ -46,7 +46,7 @@ int main() {
}

// CHECK: WARNING: ThreadSanitizer: signal handler spoils errno
// CHECK: Signal 14 handler invoked at:
// CHECK: Signal 27 handler invoked at:
// CHECK: #0 MyHandler(int, {{(__)?}}siginfo{{(_t)?}}*, void*) {{.*}}signal_errno.cpp
// CHECK: main
// CHECK: SUMMARY: ThreadSanitizer: signal handler spoils errno{{.*}}MyHandler
8 changes: 4 additions & 4 deletions compiler-rt/test/tsan/signal_reset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ static void* reset(void *p) {
struct sigaction act = {};
for (int i = 0; i < 1000000; i++) {
act.sa_handler = &handler;
if (sigaction(SIGALRM, &act, 0)) {
if (sigaction(SIGPROF, &act, 0)) {
perror("sigaction");
exit(1);
}
act.sa_handler = SIG_IGN;
if (sigaction(SIGALRM, &act, 0)) {
if (sigaction(SIGPROF, &act, 0)) {
perror("sigaction");
exit(1);
}
Expand All @@ -44,7 +44,7 @@ static void* reset(void *p) {
int main() {
struct sigaction act = {};
act.sa_handler = SIG_IGN;
if (sigaction(SIGALRM, &act, 0)) {
if (sigaction(SIGPROF, &act, 0)) {
perror("sigaction");
exit(1);
}
Expand All @@ -53,7 +53,7 @@ int main() {
t.it_value.tv_sec = 0;
t.it_value.tv_usec = 10;
t.it_interval = t.it_value;
if (setitimer(ITIMER_REAL, &t, 0)) {
if (setitimer(ITIMER_PROF, &t, 0)) {
perror("setitimer");
exit(1);
}
Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/test/tsan/signal_sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ int main() {

struct sigaction act = {};
act.sa_handler = &handler;
if (sigaction(SIGVTALRM, &act, 0)) {
if (sigaction(SIGPROF, &act, 0)) {
perror("sigaction");
exit(1);
}
Expand All @@ -39,7 +39,7 @@ int main() {
t.it_value.tv_sec = 0;
t.it_value.tv_usec = 10;
t.it_interval = t.it_value;
if (setitimer(ITIMER_VIRTUAL, &t, 0)) {
if (setitimer(ITIMER_PROF, &t, 0)) {
perror("setitimer");
exit(1);
}
Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/test/tsan/signal_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static void* thr(void *p) {
int main() {
struct sigaction act = {};
act.sa_handler = &handler;
if (sigaction(SIGVTALRM, &act, 0)) {
if (sigaction(SIGPROF, &act, 0)) {
perror("sigaction");
exit(1);
}
Expand All @@ -33,7 +33,7 @@ int main() {
t.it_value.tv_sec = 0;
t.it_value.tv_usec = 10;
t.it_interval = t.it_value;
if (setitimer(ITIMER_VIRTUAL, &t, 0)) {
if (setitimer(ITIMER_PROF, &t, 0)) {
perror("setitimer");
exit(1);
}
Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/test/tsan/signal_thread2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static void *thr(void *p) {
int main() {
struct sigaction act = {};
act.sa_handler = &handler;
if (sigaction(SIGALRM, &act, 0)) {
if (sigaction(SIGPROF, &act, 0)) {
perror("sigaction");
exit(1);
}
Expand All @@ -49,7 +49,7 @@ int main() {
t.it_value.tv_sec = 0;
t.it_value.tv_usec = 10;
t.it_interval = t.it_value;
if (setitimer(ITIMER_REAL, &t, 0)) {
if (setitimer(ITIMER_PROF, &t, 0)) {
perror("setitimer");
exit(1);
}
Expand Down