Skip to content
Closed
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
20 changes: 16 additions & 4 deletions compiler-rt/lib/sanitizer_common/sanitizer_signal_interceptors.inc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ using namespace __sanitizer;
#endif

#ifndef SIGNAL_INTERCEPTOR_SIGNAL_IMPL
#define SIGNAL_INTERCEPTOR_SIGNAL_IMPL(func, signum, handler) \
{ return REAL(func)(signum, handler); }
# define SIGNAL_INTERCEPTOR_SIGNAL_IMPL(func, signum, handler) \
{ \
ret = REAL(func)(signum, handler); \
}
#endif

#ifndef SIGNAL_INTERCEPTOR_SIGACTION_IMPL
Expand All @@ -35,17 +37,21 @@ using namespace __sanitizer;
Printf( \
"Warning: REAL(sigaction_symname) == nullptr. This may happen " \
"if you link with ubsan statically. Sigaction will not work.\n"); \
return -1; \
ret = -1; \
} else { \
ret = REAL(sigaction_symname)(signum, act, oldact); \
} \
return REAL(sigaction_symname)(signum, act, oldact); \
}
#endif

#if SANITIZER_INTERCEPT_BSD_SIGNAL
INTERCEPTOR(uptr, bsd_signal, int signum, uptr handler) {
SIGNAL_INTERCEPTOR_ENTER();
if (GetHandleSignalMode(signum) == kHandleSignalExclusive) return 0;

int ret;
SIGNAL_INTERCEPTOR_SIGNAL_IMPL(bsd_signal, signum, handler);
return ret;
}
#define INIT_BSD_SIGNAL COMMON_INTERCEPT_FUNCTION(bsd_signal)
#else // SANITIZER_INTERCEPT_BSD_SIGNAL
Expand All @@ -57,7 +63,10 @@ INTERCEPTOR(uptr, signal, int signum, uptr handler) {
SIGNAL_INTERCEPTOR_ENTER();
if (GetHandleSignalMode(signum) == kHandleSignalExclusive)
return (uptr) nullptr;

int ret;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually maybe better alternative do not change defines at all

int ret = +[](signal, signum, handler) {
SIGNAL_INTERCEPTOR_SIGNAL_IMPL(signal, signum, handler);
}(signal, signum, handler);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack, will close this pull request and use the lambdas in the other patch as needed

SIGNAL_INTERCEPTOR_SIGNAL_IMPL(signal, signum, handler);
return ret;
}
#define INIT_SIGNAL COMMON_INTERCEPT_FUNCTION(signal)

Expand All @@ -68,7 +77,10 @@ INTERCEPTOR(int, sigaction_symname, int signum,
if (!oldact) return 0;
act = nullptr;
}

uptr ret;
SIGNAL_INTERCEPTOR_SIGACTION_IMPL(signum, act, oldact);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make it
return SIGNAL_INTERCEPTOR_SIGACTION_IMPL(signum, act, oldact);?

return ret;
}
#define INIT_SIGACTION COMMON_INTERCEPT_FUNCTION(sigaction_symname)

Expand Down