// Retrieves fault PC from architecture-dependent `context`, returns 0 on failure. // Called in the context of a signal handler. static uintptr_t GetFaultPc(siginfo_t* siginfo, void* context);
// Retrieves SP from architecture-dependent `context`. // Called in the context of a signal handler. static uintptr_t GetFaultSp(void* context);
// Checks if the fault happened while running generated code. // Called in the context of a signal handler. bool IsInGeneratedCode(siginfo_t* siginfo, void *context) NO_THREAD_SAFETY_ANALYSIS;
#ifdef __aarch64__ // Update context to cause pending thread suspension request to be recognized // more quickly upon return from signal handler, if that is possible. void SuspendFaster(siginfo_t* info, void* context); #else void SuspendFaster(siginfo_t*, void*) {} #endif
// The HandleFaultByOtherHandlers function is only called by HandleFault function for generated code. bool HandleFaultByOtherHandlers(int sig, siginfo_t* info, void* context)
NO_THREAD_SAFETY_ANALYSIS;
// Check if this is an implicit suspend check that was somehow not recognized as being // in the compiled code. If that's the case, collect debugging data for the abort message // and crash. Focus on suspend checks in the boot image. Bug: 294339122 // NO_THREAD_SAFETY_ANALYSIS: Same as `IsInGeneratedCode()`. void CheckForUnrecognizedImplicitSuspendCheckInBootImage(siginfo_t* siginfo, void* context)
NO_THREAD_SAFETY_ANALYSIS;
// Note: The lock guards modifications of the ranges but the function `IsInGeneratedCode()` // walks the list in the context of a signal handler without holding the lock.
Mutex generated_code_ranges_lock_;
std::atomic<GeneratedCodeRange*> generated_code_ranges_ GUARDED_BY(generated_code_ranges_lock_);
// We keep a certain number of generated code ranges locally to avoid too many // cache misses while traversing the singly-linked list `generated_code_ranges_`. // 16 should be enough for the boot image (assuming `--multi-image`; there is // only one entry for `--single-image`), nterp, JIT code cache and a few other // entries for the app or system server. static constexpr size_t kNumLocalGeneratedCodeRanges = 16;
GeneratedCodeRange generated_code_ranges_storage_[kNumLocalGeneratedCodeRanges];
GeneratedCodeRange* free_generated_code_ranges_
GUARDED_BY(generated_code_ranges_lock_);
DISALLOW_COPY_AND_ASSIGN(FaultManager);
};
class FaultHandler { public:
EXPORT FaultHandler() {} virtual ~FaultHandler() {}
// // Null pointer fault handler // class NullPointerHandler final : public FaultHandler { public:
NullPointerHandler() {}
// NO_THREAD_SAFETY_ANALYSIS: Called after the fault manager determined that // the thread is `Runnable` and holds the mutator lock (shared) but without // telling annotalysis that we actually hold the lock. bool Action(int sig, siginfo_t* siginfo, void* context) override
NO_THREAD_SAFETY_ANALYSIS;
constexpr staticbool IsGeneratedCodeHandler() { returntrue; }
// Helper functions for checking whether the signal can be interpreted // as implicit NPE check. Note that the runtime will do more exhaustive // checks (that we cannot reasonably do in signal processing code) based // on the dex instruction faulting.
staticbool IsValidFaultAddress(uintptr_t fault_address) { // Our implicit NPE checks always limit the range to a page. return CanDoImplicitNullCheckOn(fault_address);
}
// // Stack trace handler, used to help get a stack trace from SIGSEGV inside of compiled code. // class JavaStackTraceHandler final : public FaultHandler { public: explicit JavaStackTraceHandler(FaultManager* manager) : manager_(manager) {}
#ifdef ART_USE_SIMULATOR // Simulated implicit checks will need to be handled specially because they do not originate from // native compiled code and will need to modify the simulated context before specially returning // execution to the simulator, such that it can continue simulating the quick entrypoint code // required for that specific fault.
class NullPointerHandlerSimulator final : public FaultHandler { public:
NullPointerHandlerSimulator() {}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.