Skip to content

Commit

Permalink
[vm] initialize sigaction for msan
Browse files Browse the repository at this point in the history
msan didn't recognize instance initialized with memset or bzero. Initialize all the instances.

Bug: https://buganizer.corp.google.com/issues/137630695
Change-Id: I0f4adf90cd9d4daa2abe783b1e1ca892bdacb690
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/109306
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Zichang Guo <zichangguo@google.com>
  • Loading branch information
zichangg authored and commit-bot@chromium.org committed Jul 16, 2019
1 parent 9749a83 commit 1509d9a
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 29 deletions.
4 changes: 2 additions & 2 deletions runtime/bin/ffi_test/ffi_test_functions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -704,11 +704,11 @@ void CallbackTestSignalHandler(int) {
int ExpectAbort(void (*fn)()) {
fprintf(stderr, "**** EXPECT STACKTRACE TO FOLLOW. THIS IS OK. ****\n");

struct sigaction old_action;
struct sigaction old_action = {};
int result = __sigsetjmp(buf, /*savesigs=*/1);
if (result == 0) {
// Install signal handler.
struct sigaction handler;
struct sigaction handler = {};
handler.sa_handler = CallbackTestSignalHandler;
sigemptyset(&handler.sa_mask);
handler.sa_flags = 0;
Expand Down
3 changes: 1 addition & 2 deletions runtime/bin/platform_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ bool Platform::Initialize() {
// Turn off the signal handler for SIGPIPE as it causes the process
// to terminate on writing to a closed pipe. Without the signal
// handler error EPIPE is set instead.
struct sigaction act;
bzero(&act, sizeof(act));
struct sigaction act = {};
act.sa_handler = SIG_IGN;
if (sigaction(SIGPIPE, &act, 0) != 0) {
perror("Setting signal handler failed");
Expand Down
3 changes: 1 addition & 2 deletions runtime/bin/platform_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ bool Platform::Initialize() {
// Turn off the signal handler for SIGPIPE as it causes the process
// to terminate on writing to a closed pipe. Without the signal
// handler error EPIPE is set instead.
struct sigaction act;
bzero(&act, sizeof(act));
struct sigaction act = {};
act.sa_handler = SIG_IGN;
if (sigaction(SIGPIPE, &act, 0) != 0) {
perror("Setting signal handler failed");
Expand Down
3 changes: 1 addition & 2 deletions runtime/bin/platform_macos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ bool Platform::Initialize() {
// Turn off the signal handler for SIGPIPE as it causes the process
// to terminate on writing to a closed pipe. Without the signal
// handler error EPIPE is set instead.
struct sigaction act;
bzero(&act, sizeof(act));
struct sigaction act = {};
act.sa_handler = SIG_IGN;
if (sigaction(SIGPIPE, &act, 0) != 0) {
perror("Setting signal handler failed");
Expand Down
6 changes: 2 additions & 4 deletions runtime/bin/process_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1006,8 +1006,7 @@ intptr_t Process::SetSignalHandler(intptr_t signal) {
handler = handler->next();
}
if (listen) {
struct sigaction act;
bzero(&act, sizeof(act));
struct sigaction act = {};
act.sa_handler = SignalHandler;
sigemptyset(&act.sa_mask);
for (int i = 0; i < kSignalsCount; i++) {
Expand Down Expand Up @@ -1052,8 +1051,7 @@ void Process::ClearSignalHandler(intptr_t signal, Dart_Port port) {
handler = next;
}
if (unlisten) {
struct sigaction act;
bzero(&act, sizeof(act));
struct sigaction act = {};
act.sa_handler = SIG_DFL;
VOID_NO_RETRY_EXPECTED(sigaction(signal, &act, NULL));
}
Expand Down
6 changes: 2 additions & 4 deletions runtime/bin/process_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1000,8 +1000,7 @@ intptr_t Process::SetSignalHandler(intptr_t signal) {
handler = handler->next();
}
if (listen) {
struct sigaction act;
bzero(&act, sizeof(act));
struct sigaction act = {};
act.sa_handler = SignalHandler;
sigemptyset(&act.sa_mask);
for (int i = 0; i < kSignalsCount; i++) {
Expand Down Expand Up @@ -1048,8 +1047,7 @@ void Process::ClearSignalHandler(intptr_t signal, Dart_Port port) {
handler = next;
}
if (unlisten) {
struct sigaction act;
bzero(&act, sizeof(act));
struct sigaction act = {};
act.sa_handler = SIG_DFL;
sigaction(signal, &act, NULL);
}
Expand Down
6 changes: 2 additions & 4 deletions runtime/bin/process_macos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1034,8 +1034,7 @@ intptr_t Process::SetSignalHandler(intptr_t signal) {
handler = handler->next();
}
if (listen) {
struct sigaction act;
bzero(&act, sizeof(act));
struct sigaction act = {};
act.sa_handler = SignalHandler;
sigemptyset(&act.sa_mask);
for (int i = 0; i < kSignalsCount; i++) {
Expand Down Expand Up @@ -1084,8 +1083,7 @@ void Process::ClearSignalHandler(intptr_t signal, Dart_Port port) {
handler = next;
}
if (unlisten) {
struct sigaction act;
bzero(&act, sizeof(act));
struct sigaction act = {};
act.sa_handler = SIG_DFL;
VOID_NO_RETRY_EXPECTED(sigaction(signal, &act, NULL));
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/platform/memory_sanitizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// told about areas that are initialized by generated code.
#if defined(__has_feature)
#if __has_feature(memory_sanitizer)
extern "C" void __msan_unpoison(void*, size_t);
extern "C" void __msan_unpoison(const volatile void*, size_t);
#define MSAN_UNPOISON(ptr, len) __msan_unpoison(ptr, len)
#define NO_SANITIZE_MEMORY __attribute__((no_sanitize_memory))
#else // __has_feature(memory_sanitizer)
Expand Down
6 changes: 2 additions & 4 deletions runtime/vm/signal_handler_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ uintptr_t SignalHandler::GetLinkRegister(const mcontext_t& mcontext) {
}

void SignalHandler::InstallImpl(SignalAction action) {
struct sigaction act;
memset(&act, 0, sizeof(act));
struct sigaction act = {};
act.sa_sigaction = action;
sigemptyset(&act.sa_mask);
act.sa_flags = SA_RESTART | SA_SIGINFO;
Expand All @@ -107,8 +106,7 @@ void SignalHandler::InstallImpl(SignalAction action) {
void SignalHandler::Remove() {
// Ignore future SIGPROF signals because by default SIGPROF will terminate
// the process and we may have some signals in flight.
struct sigaction act;
memset(&act, 0, sizeof(act));
struct sigaction act = {};
act.sa_handler = SIG_IGN;
sigemptyset(&act.sa_mask);
int r = sigaction(SIGPROF, &act, NULL);
Expand Down
4 changes: 2 additions & 2 deletions runtime/vm/signal_handler_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ uintptr_t SignalHandler::GetLinkRegister(const mcontext_t& mcontext) {
}

void SignalHandler::InstallImpl(SignalAction action) {
struct sigaction act;
struct sigaction act = {};
act.sa_handler = NULL;
act.sa_sigaction = action;
sigemptyset(&act.sa_mask);
Expand All @@ -107,7 +107,7 @@ void SignalHandler::InstallImpl(SignalAction action) {
void SignalHandler::Remove() {
// Ignore future SIGPROF signals because by default SIGPROF will terminate
// the process and we may have some signals in flight.
struct sigaction act;
struct sigaction act = {};
act.sa_handler = SIG_IGN;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
Expand Down
4 changes: 2 additions & 2 deletions runtime/vm/signal_handler_macos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ uintptr_t SignalHandler::GetLinkRegister(const mcontext_t& mcontext) {
}

void SignalHandler::InstallImpl(SignalAction action) {
struct sigaction act;
struct sigaction act = {};
act.sa_handler = NULL;
act.sa_sigaction = action;
sigemptyset(&act.sa_mask);
Expand All @@ -103,7 +103,7 @@ void SignalHandler::InstallImpl(SignalAction action) {
void SignalHandler::Remove() {
// Ignore future SIGPROF signals because by default SIGPROF will terminate
// the process and we may have some signals in flight.
struct sigaction act;
struct sigaction act = {};
act.sa_handler = SIG_IGN;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
Expand Down

0 comments on commit 1509d9a

Please sign in to comment.