summaryrefslogtreecommitdiff
path: root/runtime/fault_handler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/fault_handler.cc')
-rw-r--r--runtime/fault_handler.cc28
1 files changed, 20 insertions, 8 deletions
diff --git a/runtime/fault_handler.cc b/runtime/fault_handler.cc
index fede2f8ec3..4ae929b0cc 100644
--- a/runtime/fault_handler.cc
+++ b/runtime/fault_handler.cc
@@ -95,16 +95,29 @@ FaultManager::FaultManager() : initialized_(false) {
FaultManager::~FaultManager() {
}
+static void SetUpArtAction(struct sigaction* action) {
+ action->sa_sigaction = art_fault_handler;
+ sigemptyset(&action->sa_mask);
+ action->sa_flags = SA_SIGINFO | SA_ONSTACK;
+#if !defined(__APPLE__) && !defined(__mips__)
+ action->sa_restorer = nullptr;
+#endif
+}
+
+void FaultManager::EnsureArtActionInFrontOfSignalChain() {
+ if (initialized_) {
+ struct sigaction action;
+ SetUpArtAction(&action);
+ EnsureFrontOfChain(SIGSEGV, &action);
+ } else {
+ LOG(WARNING) << "Can't call " << __FUNCTION__ << " due to unitialized fault manager";
+ }
+}
void FaultManager::Init() {
CHECK(!initialized_);
struct sigaction action;
- action.sa_sigaction = art_fault_handler;
- sigemptyset(&action.sa_mask);
- action.sa_flags = SA_SIGINFO | SA_ONSTACK;
-#if !defined(__APPLE__) && !defined(__mips__)
- action.sa_restorer = nullptr;
-#endif
+ SetUpArtAction(&action);
// Set our signal handler now.
int e = sigaction(SIGSEGV, &action, &oldaction_);
@@ -138,7 +151,6 @@ void FaultManager::HandleFault(int sig, siginfo_t* info, void* context) {
//
// If malloc calls abort, it will be holding its lock.
// If the handler tries to call malloc, it will deadlock.
-
VLOG(signals) << "Handling fault";
if (IsInGeneratedCode(info, context, true)) {
VLOG(signals) << "in generated code, looking for handler";
@@ -388,7 +400,7 @@ bool JavaStackTraceHandler::Action(int sig, siginfo_t* siginfo, void* context) {
// Inside of generated code, sp[0] is the method, so sp is the frame.
StackReference<mirror::ArtMethod>* frame =
reinterpret_cast<StackReference<mirror::ArtMethod>*>(sp);
- self->SetTopOfStack(frame, 0); // Since we don't necessarily have a dex pc, pass in 0.
+ self->SetTopOfStack(frame);
#ifdef TEST_NESTED_SIGNAL
// To test the nested signal handler we raise a signal here. This will cause the
// nested signal handler to be called and perform a longjmp back to the setjmp