Skip to content

Commit 47abf88

Browse files
committed
[NFCI][sanitizer] Refactor SIGNAL_INTERCEPTOR_SIGACTION_IMPL to not immediately return
This enables follow-up work (llvm#162746), which will inspect the return value and do additional work before returning.
1 parent 9f0f6e8 commit 47abf88

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_signal_interceptors.inc

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ using namespace __sanitizer;
2424
#endif
2525

2626
#ifndef SIGNAL_INTERCEPTOR_SIGNAL_IMPL
27-
#define SIGNAL_INTERCEPTOR_SIGNAL_IMPL(func, signum, handler) \
28-
{ return REAL(func)(signum, handler); }
27+
# define SIGNAL_INTERCEPTOR_SIGNAL_IMPL(func, signum, handler) \
28+
{ \
29+
ret = REAL(func)(signum, handler); \
30+
}
2931
#endif
3032

3133
#ifndef SIGNAL_INTERCEPTOR_SIGACTION_IMPL
@@ -35,17 +37,20 @@ using namespace __sanitizer;
3537
Printf( \
3638
"Warning: REAL(sigaction_symname) == nullptr. This may happen " \
3739
"if you link with ubsan statically. Sigaction will not work.\n"); \
38-
return -1; \
40+
ret = -1; \
3941
} \
40-
return REAL(sigaction_symname)(signum, act, oldact); \
42+
ret = REAL(sigaction_symname)(signum, act, oldact); \
4143
}
4244
#endif
4345

4446
#if SANITIZER_INTERCEPT_BSD_SIGNAL
4547
INTERCEPTOR(uptr, bsd_signal, int signum, uptr handler) {
4648
SIGNAL_INTERCEPTOR_ENTER();
4749
if (GetHandleSignalMode(signum) == kHandleSignalExclusive) return 0;
50+
51+
int ret;
4852
SIGNAL_INTERCEPTOR_SIGNAL_IMPL(bsd_signal, signum, handler);
53+
return ret;
4954
}
5055
#define INIT_BSD_SIGNAL COMMON_INTERCEPT_FUNCTION(bsd_signal)
5156
#else // SANITIZER_INTERCEPT_BSD_SIGNAL
@@ -57,7 +62,10 @@ INTERCEPTOR(uptr, signal, int signum, uptr handler) {
5762
SIGNAL_INTERCEPTOR_ENTER();
5863
if (GetHandleSignalMode(signum) == kHandleSignalExclusive)
5964
return (uptr) nullptr;
65+
66+
int ret;
6067
SIGNAL_INTERCEPTOR_SIGNAL_IMPL(signal, signum, handler);
68+
return ret;
6169
}
6270
#define INIT_SIGNAL COMMON_INTERCEPT_FUNCTION(signal)
6371

@@ -68,7 +76,10 @@ INTERCEPTOR(int, sigaction_symname, int signum,
6876
if (!oldact) return 0;
6977
act = nullptr;
7078
}
79+
80+
uptr ret;
7181
SIGNAL_INTERCEPTOR_SIGACTION_IMPL(signum, act, oldact);
82+
return ret;
7283
}
7384
#define INIT_SIGACTION COMMON_INTERCEPT_FUNCTION(sigaction_symname)
7485

0 commit comments

Comments
 (0)