-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
Reapply "[sanitizer_common] AND signals in BlockSignals instead of deleting (#113443)" for non-Android Linux only #115790
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3f043e1
Reapply "[sanitizer_common] AND signals in BlockSignals instead of de…
thurstond e88b5fc
Revert to pre-#98200 behavior for Android
thurstond 5789cca
Add FIXME
thurstond 7558d41
Add https://github.com/google/sanitizers/issues/1816 to FIXMEs
thurstond 8ec1550
Add SANITIZER_LINUX guard
thurstond 625f812
Refactor
thurstond a6988aa
Fix logic error pointed out by Vitaly
thurstond 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 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
This file contains 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
76 changes: 76 additions & 0 deletions
76
compiler-rt/lib/sanitizer_common/tests/sanitizer_block_signals.cpp
This file contains 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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
//===-- sanitizer_block_signals.cpp ---------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file is a part of sanitizer_common unit tests. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
#include <signal.h> | ||
#include <stdio.h> | ||
|
||
#include "gtest/gtest.h" | ||
#include "sanitizer_common/sanitizer_linux.h" | ||
|
||
namespace __sanitizer { | ||
|
||
#if SANITIZER_LINUX && !SANITIZER_ANDROID | ||
volatile int received_sig = -1; | ||
|
||
void signal_handler(int signum) { received_sig = signum; } | ||
|
||
TEST(SanitizerCommon, NoBlockSignals) { | ||
// No signals blocked | ||
signal(SIGUSR1, signal_handler); | ||
raise(SIGUSR1); | ||
EXPECT_EQ(received_sig, SIGUSR1); | ||
|
||
received_sig = -1; | ||
signal(SIGPIPE, signal_handler); | ||
raise(SIGPIPE); | ||
EXPECT_EQ(received_sig, SIGPIPE); | ||
} | ||
|
||
TEST(SanitizerCommon, BlockSignalsPlain) { | ||
// ScopedBlockSignals; SIGUSR1 should be blocked but not SIGPIPE | ||
{ | ||
__sanitizer_sigset_t sigset = {}; | ||
ScopedBlockSignals block(&sigset); | ||
|
||
received_sig = -1; | ||
signal(SIGUSR1, signal_handler); | ||
raise(SIGUSR1); | ||
EXPECT_EQ(received_sig, -1); | ||
|
||
received_sig = -1; | ||
signal(SIGPIPE, signal_handler); | ||
raise(SIGPIPE); | ||
EXPECT_EQ(received_sig, SIGPIPE); | ||
} | ||
EXPECT_EQ(received_sig, SIGUSR1); | ||
} | ||
|
||
TEST(SanitizerCommon, BlockSignalsExceptPipe) { | ||
// Manually block SIGPIPE; ScopedBlockSignals should not unblock this | ||
sigset_t block_sigset; | ||
sigemptyset(&block_sigset); | ||
sigaddset(&block_sigset, SIGPIPE); | ||
sigprocmask(SIG_BLOCK, &block_sigset, NULL); | ||
{ | ||
__sanitizer_sigset_t sigset = {}; | ||
ScopedBlockSignals block(&sigset); | ||
|
||
received_sig = -1; | ||
signal(SIGPIPE, signal_handler); | ||
raise(SIGPIPE); | ||
EXPECT_EQ(received_sig, -1); | ||
} | ||
sigprocmask(SIG_UNBLOCK, &block_sigset, NULL); | ||
EXPECT_EQ(received_sig, SIGPIPE); | ||
} | ||
#endif // SANITIZER_LINUX && !SANITIZER_ANDROID | ||
|
||
} // namespace __sanitizer |
Oops, something went wrong.
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.
unused current set warning is possible on non-linux.
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.
Thanks, will fix
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.
we still need
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.
Oops, thank you!