Ignore:
Timestamp:
Apr 21, 2017, 1:31:39 PM (8 years ago)
Author:
[email protected]
Message:

Unreviewed, rolling out r215620 and r215623.
https://bugs.webkit.org/show_bug.cgi?id=171139

broke arm64 build (Requested by keith_miller on #webkit).

Reverted changesets:

"Add signaling API"
https://bugs.webkit.org/show_bug.cgi?id=170976
http://trac.webkit.org/changeset/215620

"Unreviewed, fix Cloop build."
http://trac.webkit.org/changeset/215623

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/tools/SigillCrashAnalyzer.cpp

    r215620 r215634  
    3838#endif
    3939
    40 #include <wtf/threads/Signals.h>
     40#if HAVE(SIGNAL_H)
     41#include <signal.h>
     42#endif
    4143
    4244namespace JSC {
     
    140142};
    141143
     144struct sigaction originalSigIllAction;
     145
     146static void handleCrash(int signalNumber, siginfo_t* info, void* uap)
     147{
     148    SignalContext context(static_cast<ucontext_t*>(uap)->uc_mcontext);
     149    SigillCrashAnalyzer& analyzer = SigillCrashAnalyzer::instance();
     150    auto crashSource = analyzer.analyze(context);
     151
     152    auto originalAction = originalSigIllAction.sa_sigaction;
     153    if (originalAction) {
     154        // It is always safe to just invoke the original handler using the sa_sigaction form
     155        // without checking for the SA_SIGINFO flag. If the original handler is of the
     156        // sa_handler form, it will just ignore the 2nd and 3rd arguments since sa_handler is a
     157        // subset of sa_sigaction. This is what the man pages says the OS does anyway.
     158        originalAction(signalNumber, info, uap);
     159    }
     160
     161    if (crashSource == SigillCrashAnalyzer::CrashSource::JavaScriptCore) {
     162        // Restore the default handler so that we can get a core dump.
     163        struct sigaction defaultAction;
     164        defaultAction.sa_handler = SIG_DFL;
     165        sigfillset(&defaultAction.sa_mask);
     166        defaultAction.sa_flags = 0;
     167        sigaction(SIGILL, &defaultAction, nullptr);
     168    } else if (!originalAction) {
     169        // Pre-emptively restore the default handler but we may roll it back below.
     170        struct sigaction currentAction;
     171        struct sigaction defaultAction;
     172        defaultAction.sa_handler = SIG_DFL;
     173        sigfillset(&defaultAction.sa_mask);
     174        defaultAction.sa_flags = 0;
     175        sigaction(SIGILL, &defaultAction, &currentAction);
     176
     177        if (currentAction.sa_sigaction != handleCrash) {
     178            // This means that there's a client handler installed after us. This also means
     179            // that the client handler thinks it was able to recover from the SIGILL, and
     180            // did not uninstall itself. We can't argue with this because the crash isn't
     181            // known to be from a JavaScriptCore source. Hence, restore the client handler
     182            // and keep going.
     183            sigaction(SIGILL, &currentAction, nullptr);
     184        }
     185    }
     186}
     187
    142188static void installCrashHandler()
    143189{
    144190#if CPU(X86_64) || CPU(ARM64)
    145     installSignalHandler(Signal::Ill, [] (int, siginfo_t*, void* uap) {
    146         SignalContext context(static_cast<ucontext_t*>(uap)->uc_mcontext);
    147 
    148         if (!isJITPC(context.machinePC))
    149             return SignalAction::NotHandled;
    150 
    151         SigillCrashAnalyzer& analyzer = SigillCrashAnalyzer::instance();
    152         analyzer.analyze(context);
    153         return SignalAction::NotHandled;
    154     });
     191    struct sigaction action;
     192    action.sa_sigaction = reinterpret_cast<void (*)(int, siginfo_t *, void *)>(handleCrash);
     193    sigfillset(&action.sa_mask);
     194    action.sa_flags = SA_SIGINFO;
     195    sigaction(SIGILL, &action, &originalSigIllAction);
     196#else
     197    UNUSED_PARAM(handleCrash);
    155198#endif
    156199}
Note: See TracChangeset for help on using the changeset viewer.