Changeset 215634 in webkit for trunk/Source/JavaScriptCore/tools/SigillCrashAnalyzer.cpp
- Timestamp:
- Apr 21, 2017, 1:31:39 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/tools/SigillCrashAnalyzer.cpp
r215620 r215634 38 38 #endif 39 39 40 #include <wtf/threads/Signals.h> 40 #if HAVE(SIGNAL_H) 41 #include <signal.h> 42 #endif 41 43 42 44 namespace JSC { … … 140 142 }; 141 143 144 struct sigaction originalSigIllAction; 145 146 static 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, ¤tAction); 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, ¤tAction, nullptr); 184 } 185 } 186 } 187 142 188 static void installCrashHandler() 143 189 { 144 190 #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); 155 198 #endif 156 199 }
Note:
See TracChangeset
for help on using the changeset viewer.