This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] Don't intercept signal and sigaction on Fuchsia
ClosedPublic

Authored by phosek on Oct 7 2017, 7:58 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

phosek created this revision.Oct 7 2017, 7:58 PM
mcgrathr requested changes to this revision.Oct 7 2017, 8:24 PM

What effect does this have?
Nothing built for Fuchsia ought to be using sanitizer_signal_interceptors.inc or HandleDeadlySignal in the first place.

This revision now requires changes to proceed.Oct 7 2017, 8:24 PM

This is used from ubsan_signals_standalone.cc. Alternative would be to exclude it from UBSan's CMakeLists.txt when compiling for Fuchsia and avoid the invocation of InitializeDeadlySignals() on Fuchsia in ubsan_init_standalone.cc.

The effect this will have is none, because InstallDeadlySignalHandlers which is supposed to install signal handles doesn't do anything on Fuchsia, see sanitizer_fuchsia.cc. Without the empty definition of HandleDeadlySignal, the build is broken because there's an undefined reference to it in UBsanOnDeadlySignal in ubsan_signals_standalone.cc.

I wonder why my builds have never had an undefined symbol HandleDeadlySignal.

The norm in the sanitizer code for the most part is to #if out whole files rather than conditionalizing it in cmake.

Since we don't have or need a ubsan_fuchsia.cc, I'd just selectively #if out most of uban_signals_standalone.cc so that InitializeDeadSignals is a no-op for SANITIZER_FUCHSIA.

phosek updated this revision to Diff 118177.Oct 8 2017, 4:00 PM
phosek edited edge metadata.

Done. This is a new code hence why you haven't hit it in the past.

phosek updated this revision to Diff 118178.Oct 8 2017, 4:03 PM
vitalybuka added inline comments.Oct 9 2017, 10:06 AM
lib/ubsan/ubsan_signals_standalone.cc
27 ↗(On Diff #118178)

Could you please either create _fuchsia.cc file or
consolidate code into single #if

e.g.:

#if SANITIZER_FUCHSIA 

void InitializeDeadlySignals() {}

#else

static void OnStackUnwind(const SignalContext &sig, const void *,
                          BufferedStackTrace *stack) {
...
}

static void UBsanOnDeadlySignal(int signo, void *siginfo, void *context) {
...
}
static bool is_initialized = false;

void InitializeDeadlySignals() {
  if (is_initialized)
    return;
  is_initialized = true;
  InitializeSignalInterceptors();
  InstallDeadlySignalHandlers(&UBsanOnDeadlySignal);
}

#endif
phosek updated this revision to Diff 118237.Oct 9 2017, 11:02 AM
phosek marked an inline comment as done.
vitalybuka accepted this revision.Oct 9 2017, 11:05 AM
This revision was automatically updated to reflect the committed changes.