Changeset 211828 in webkit for trunk/Source/JavaScriptCore/tools/SigillCrashAnalyzer.cpp
- Timestamp:
- Feb 7, 2017, 12:01:35 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/tools/SigillCrashAnalyzer.cpp
r211684 r211828 48 48 public: 49 49 static SigillCrashAnalyzer& instance(); 50 void analyze(SignalContext&); 50 51 enum class CrashSource { 52 Unknown, 53 JavaScriptCore, 54 Other, 55 }; 56 CrashSource analyze(SignalContext&); 51 57 52 58 private: … … 166 172 #endif 167 173 168 struct sigaction oldSigIllAction; 169 170 static void handleCrash(int, siginfo_t*, void* uap) 171 { 172 sigaction(SIGILL, &oldSigIllAction, nullptr); 173 174 struct sigaction originalSigIllAction; 175 176 static void handleCrash(int signalNumber, siginfo_t* info, void* uap) 177 { 174 178 SignalContext context(static_cast<ucontext_t*>(uap)->uc_mcontext); 175 179 SigillCrashAnalyzer& analyzer = SigillCrashAnalyzer::instance(); 176 analyzer.analyze(context); 180 auto crashSource = analyzer.analyze(context); 181 182 auto originalAction = originalSigIllAction.sa_sigaction; 183 if (originalAction) { 184 // It is always safe to just invoke the original handler using the sa_sigaction form 185 // without checking for the SA_SIGINFO flag. If the original handler is of the 186 // sa_handler form, it will just ignore the 2nd and 3rd arguments since sa_handler is a 187 // subset of sa_sigaction. This is what the man pages says the OS does anyway. 188 originalAction(signalNumber, info, uap); 189 } 190 191 if (crashSource == SigillCrashAnalyzer::CrashSource::JavaScriptCore) { 192 // Restore the default handler so that we can get a core dump. 193 struct sigaction defaultAction; 194 defaultAction.sa_handler = SIG_DFL; 195 sigfillset(&defaultAction.sa_mask); 196 defaultAction.sa_flags = 0; 197 sigaction(SIGILL, &defaultAction, nullptr); 198 } else if (!originalAction) { 199 // Pre-emptively restore the default handler but we may roll it back below. 200 struct sigaction currentAction; 201 struct sigaction defaultAction; 202 defaultAction.sa_handler = SIG_DFL; 203 sigfillset(&defaultAction.sa_mask); 204 defaultAction.sa_flags = 0; 205 sigaction(SIGILL, &defaultAction, ¤tAction); 206 207 if (currentAction.sa_sigaction != handleCrash) { 208 // This means that there's a client handler installed after us. This also means 209 // that the client handler thinks it was able to recover from the SIGILL, and 210 // did not uninstall itself. We can't argue with this because the crash isn't 211 // known to be from a JavaScriptCore source. Hence, restore the client handler 212 // and keep going. 213 sigaction(SIGILL, ¤tAction, nullptr); 214 } 215 } 177 216 } 178 217 … … 184 223 sigfillset(&action.sa_mask); 185 224 action.sa_flags = SA_SIGINFO; 186 sigaction(SIGILL, &action, &o ldSigIllAction);225 sigaction(SIGILL, &action, &originalSigIllAction); 187 226 #else 188 227 UNUSED_PARAM(handleCrash); … … 228 267 } 229 268 230 void SigillCrashAnalyzer::analyze(SignalContext& context) 231 { 269 auto SigillCrashAnalyzer::analyze(SignalContext& context) -> CrashSource 270 { 271 CrashSource crashSource = CrashSource::Unknown; 232 272 log("BEGIN SIGILL analysis"); 233 273 … … 258 298 if (!isInJITMemory.value()) { 259 299 log("pc %p is NOT in valid JIT executable memory", pc); 300 crashSource = CrashSource::Other; 260 301 return; 261 302 } 262 303 log("pc %p is in valid JIT executable memory", pc); 304 crashSource = CrashSource::JavaScriptCore; 263 305 264 306 #if CPU(ARM64) … … 295 337 296 338 log("END SIGILL analysis"); 339 return crashSource; 297 340 } 298 341
Note:
See TracChangeset
for help on using the changeset viewer.