-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[NFCI][sanitizer] Refactor SIGNAL_INTERCEPTOR_SIGACTION_IMPL to not immediately return #162916
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -57,7 +63,10 @@ INTERCEPTOR(uptr, signal, int signum, uptr handler) { | |
SIGNAL_INTERCEPTOR_ENTER(); | ||
if (GetHandleSignalMode(signum) == kHandleSignalExclusive) | ||
return (uptr) nullptr; | ||
|
||
int ret; | ||
SIGNAL_INTERCEPTOR_SIGNAL_IMPL(signal, signum, handler); | ||
return ret; | ||
} | ||
#define INIT_SIGNAL COMMON_INTERCEPT_FUNCTION(signal) | ||
|
||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we make it |
||
return ret; | ||
} | ||
#define INIT_SIGACTION COMMON_INTERCEPT_FUNCTION(sigaction_symname) | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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);
There was a problem hiding this comment.
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