blob: 4a352ddf9aecca0ca1817e7807113f58d54ad63d [file] [log] [blame]
Dave Allisonb373e092014-02-20 16:06:36 -08001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "fault_handler.h"
Ian Rogers22d5e732014-07-15 22:23:51 -070018
Dave Allison8ce6b902014-08-26 11:07:58 -070019#include <setjmp.h>
Dave Allisonb373e092014-02-20 16:06:36 -080020#include <sys/mman.h>
21#include <sys/ucontext.h>
Mathieu Chartiere401d142015-04-22 13:56:20 -070022
23#include "art_method-inl.h"
Andreas Gampe928f72b2014-09-09 19:53:48 -070024#include "base/stl_util.h"
Ian Rogers22d5e732014-07-15 22:23:51 -070025#include "mirror/class.h"
Dave Allisonf4b80bc2014-05-14 15:41:25 -070026#include "sigchain.h"
Ian Rogers22d5e732014-07-15 22:23:51 -070027#include "thread-inl.h"
Dave Allisonb373e092014-02-20 16:06:36 -080028#include "verify_object-inl.h"
29
Dave Allison8ce6b902014-08-26 11:07:58 -070030// Note on nested signal support
31// -----------------------------
32//
33// Typically a signal handler should not need to deal with signals that occur within it.
34// However, when a SIGSEGV occurs that is in generated code and is not one of the
35// handled signals (implicit checks), we call a function to try to dump the stack
36// to the log. This enhances the debugging experience but may have the side effect
37// that it may not work. If the cause of the original SIGSEGV is a corrupted stack or other
38// memory region, the stack backtrace code may run into trouble and may either crash
39// or fail with an abort (SIGABRT). In either case we don't want that (new) signal to
40// mask the original signal and thus prevent useful debug output from being presented.
41//
42// In order to handle this situation, before we call the stack tracer we do the following:
43//
44// 1. shutdown the fault manager so that we are talking to the real signal management
45// functions rather than those in sigchain.
46// 2. use pthread_sigmask to allow SIGSEGV and SIGABRT signals to be delivered to the
47// thread running the signal handler.
48// 3. set the handler for SIGSEGV and SIGABRT to a secondary signal handler.
49// 4. save the thread's state to the TLS of the current thread using 'setjmp'
50//
51// We then call the stack tracer and one of two things may happen:
52// a. it completes successfully
53// b. it crashes and a signal is raised.
54//
55// In the former case, we fall through and everything is fine. In the latter case
56// our secondary signal handler gets called in a signal context. This results in
57// a call to FaultManager::HandledNestedSignal(), an archirecture specific function
58// whose purpose is to call 'longjmp' on the jmp_buf saved in the TLS of the current
59// thread. This results in a return with a non-zero value from 'setjmp'. We detect this
60// and write something to the log to tell the user that it happened.
61//
62// Regardless of how we got there, we reach the code after the stack tracer and we
63// restore the signal states to their original values, reinstate the fault manager (thus
64// reestablishing the signal chain) and continue.
65
66// This is difficult to test with a runtime test. To invoke the nested signal code
67// on any signal, uncomment the following line and run something that throws a
68// NullPointerException.
69// #define TEST_NESTED_SIGNAL
70
Dave Allisonb373e092014-02-20 16:06:36 -080071namespace art {
72// Static fault manger object accessed by signal handler.
73FaultManager fault_manager;
74
Dave Allisonf4b80bc2014-05-14 15:41:25 -070075extern "C" {
76void art_sigsegv_fault() {
77 // Set a breakpoint here to be informed when a SIGSEGV is unhandled by ART.
78 VLOG(signals)<< "Caught unknown SIGSEGV in ART fault handler - chaining to next handler.";
79}
80}
81
Dave Allisonb373e092014-02-20 16:06:36 -080082// Signal handler called on SIGSEGV.
83static void art_fault_handler(int sig, siginfo_t* info, void* context) {
84 fault_manager.HandleFault(sig, info, context);
85}
86
Dave Allison8ce6b902014-08-26 11:07:58 -070087// Signal handler for dealing with a nested signal.
88static void art_nested_signal_handler(int sig, siginfo_t* info, void* context) {
89 fault_manager.HandleNestedSignal(sig, info, context);
90}
91
Dave Allison1f8ef6f2014-08-20 17:38:41 -070092FaultManager::FaultManager() : initialized_(false) {
Dave Allisonb373e092014-02-20 16:06:36 -080093 sigaction(SIGSEGV, nullptr, &oldaction_);
94}
95
96FaultManager::~FaultManager() {
Dave Allisonb373e092014-02-20 16:06:36 -080097}
98
Mathieu Chartierd0004802014-10-15 16:59:47 -070099static void SetUpArtAction(struct sigaction* action) {
100 action->sa_sigaction = art_fault_handler;
101 sigemptyset(&action->sa_mask);
102 action->sa_flags = SA_SIGINFO | SA_ONSTACK;
103#if !defined(__APPLE__) && !defined(__mips__)
104 action->sa_restorer = nullptr;
105#endif
106}
107
108void FaultManager::EnsureArtActionInFrontOfSignalChain() {
109 if (initialized_) {
110 struct sigaction action;
111 SetUpArtAction(&action);
112 EnsureFrontOfChain(SIGSEGV, &action);
113 } else {
114 LOG(WARNING) << "Can't call " << __FUNCTION__ << " due to unitialized fault manager";
115 }
116}
Dave Allisonf4b80bc2014-05-14 15:41:25 -0700117
Dave Allisonb373e092014-02-20 16:06:36 -0800118void FaultManager::Init() {
Dave Allison1f8ef6f2014-08-20 17:38:41 -0700119 CHECK(!initialized_);
Dave Allisonb373e092014-02-20 16:06:36 -0800120 struct sigaction action;
Mathieu Chartierd0004802014-10-15 16:59:47 -0700121 SetUpArtAction(&action);
Dave Allisonf4b80bc2014-05-14 15:41:25 -0700122
123 // Set our signal handler now.
Dave Allison69dfe512014-07-11 17:11:58 +0000124 int e = sigaction(SIGSEGV, &action, &oldaction_);
125 if (e != 0) {
126 VLOG(signals) << "Failed to claim SEGV: " << strerror(errno);
127 }
Dave Allisonf4b80bc2014-05-14 15:41:25 -0700128 // Make sure our signal handler is called before any user handlers.
129 ClaimSignalChain(SIGSEGV, &oldaction_);
Dave Allison1f8ef6f2014-08-20 17:38:41 -0700130 initialized_ = true;
131}
132
Andreas Gampe928f72b2014-09-09 19:53:48 -0700133void FaultManager::Release() {
Dave Allison1f8ef6f2014-08-20 17:38:41 -0700134 if (initialized_) {
135 UnclaimSignalChain(SIGSEGV);
136 initialized_ = false;
137 }
Dave Allisonb373e092014-02-20 16:06:36 -0800138}
139
Andreas Gampe928f72b2014-09-09 19:53:48 -0700140void FaultManager::Shutdown() {
141 if (initialized_) {
142 Release();
143
144 // Free all handlers.
145 STLDeleteElements(&generated_code_handlers_);
146 STLDeleteElements(&other_handlers_);
147 }
148}
149
Dave Allisonb373e092014-02-20 16:06:36 -0800150void FaultManager::HandleFault(int sig, siginfo_t* info, void* context) {
Brian Carlstrom4d466a82014-05-08 19:05:29 -0700151 // BE CAREFUL ALLOCATING HERE INCLUDING USING LOG(...)
152 //
153 // If malloc calls abort, it will be holding its lock.
154 // If the handler tries to call malloc, it will deadlock.
155 VLOG(signals) << "Handling fault";
Dave Allison69dfe512014-07-11 17:11:58 +0000156 if (IsInGeneratedCode(info, context, true)) {
Brian Carlstrom4d466a82014-05-08 19:05:29 -0700157 VLOG(signals) << "in generated code, looking for handler";
Mathieu Chartierc751fdc2014-03-30 15:25:44 -0700158 for (const auto& handler : generated_code_handlers_) {
Brian Carlstrom4d466a82014-05-08 19:05:29 -0700159 VLOG(signals) << "invoking Action on handler " << handler;
Mathieu Chartierc751fdc2014-03-30 15:25:44 -0700160 if (handler->Action(sig, info, context)) {
Dave Allison8ce6b902014-08-26 11:07:58 -0700161#ifdef TEST_NESTED_SIGNAL
162 // In test mode we want to fall through to stack trace handler
163 // on every signal (in reality this will cause a crash on the first
164 // signal).
165 break;
166#else
167 // We have handled a signal so it's time to return from the
168 // signal handler to the appropriate place.
Dave Allisonb373e092014-02-20 16:06:36 -0800169 return;
Dave Allison8ce6b902014-08-26 11:07:58 -0700170#endif
Dave Allisonb373e092014-02-20 16:06:36 -0800171 }
172 }
173 }
Dave Allison8ce6b902014-08-26 11:07:58 -0700174
175 // We hit a signal we didn't handle. This might be something for which
176 // we can give more information about so call all registered handlers to see
177 // if it is.
Dave Allison0c2894b2014-08-29 12:06:16 -0700178
179 Thread* self = Thread::Current();
180
Christopher Ferris5e2b8742014-11-18 15:50:47 -0800181 // If ART is not running, or the thread is not attached to ART pass the
182 // signal on to the next handler in the chain.
183 if (self == nullptr || Runtime::Current() == nullptr || !Runtime::Current()->IsStarted()) {
184 InvokeUserSignalHandler(sig, info, context);
185 return;
186 }
Dave Allison0c2894b2014-08-29 12:06:16 -0700187 // Now set up the nested signal handler.
188
Ian Rogersad11e7a2014-11-11 16:55:11 -0800189 // TODO: add SIGSEGV back to the nested signals when we can handle running out stack gracefully.
190 static const int handled_nested_signals[] = {SIGABRT};
191 constexpr size_t num_handled_nested_signals = arraysize(handled_nested_signals);
192
Andreas Gampe928f72b2014-09-09 19:53:48 -0700193 // Release the fault manager so that it will remove the signal chain for
Dave Allison0c2894b2014-08-29 12:06:16 -0700194 // SIGSEGV and we call the real sigaction.
Andreas Gampe928f72b2014-09-09 19:53:48 -0700195 fault_manager.Release();
Dave Allison0c2894b2014-08-29 12:06:16 -0700196
197 // The action for SIGSEGV should be the default handler now.
198
199 // Unblock the signals we allow so that they can be delivered in the signal handler.
200 sigset_t sigset;
201 sigemptyset(&sigset);
Ian Rogersad11e7a2014-11-11 16:55:11 -0800202 for (int signal : handled_nested_signals) {
203 sigaddset(&sigset, signal);
204 }
Dave Allison0c2894b2014-08-29 12:06:16 -0700205 pthread_sigmask(SIG_UNBLOCK, &sigset, nullptr);
206
207 // If we get a signal in this code we want to invoke our nested signal
208 // handler.
Ian Rogersad11e7a2014-11-11 16:55:11 -0800209 struct sigaction action;
210 struct sigaction oldactions[num_handled_nested_signals];
Dave Allison0c2894b2014-08-29 12:06:16 -0700211 action.sa_sigaction = art_nested_signal_handler;
212
213 // Explicitly mask out SIGSEGV and SIGABRT from the nested signal handler. This
214 // should be the default but we definitely don't want these happening in our
215 // nested signal handler.
216 sigemptyset(&action.sa_mask);
Ian Rogersad11e7a2014-11-11 16:55:11 -0800217 for (int signal : handled_nested_signals) {
218 sigaddset(&action.sa_mask, signal);
219 }
Dave Allison0c2894b2014-08-29 12:06:16 -0700220
221 action.sa_flags = SA_SIGINFO | SA_ONSTACK;
222#if !defined(__APPLE__) && !defined(__mips__)
223 action.sa_restorer = nullptr;
224#endif
225
Ian Rogersad11e7a2014-11-11 16:55:11 -0800226 // Catch handled signals to invoke our nested handler.
227 bool success = true;
228 for (size_t i = 0; i < num_handled_nested_signals; ++i) {
229 success = sigaction(handled_nested_signals[i], &action, &oldactions[i]) == 0;
230 if (!success) {
231 PLOG(ERROR) << "Unable to set up nested signal handler";
232 break;
233 }
234 }
235 if (success) {
Dave Allison0c2894b2014-08-29 12:06:16 -0700236 // Save the current state and call the handlers. If anything causes a signal
237 // our nested signal handler will be invoked and this will longjmp to the saved
238 // state.
239 if (setjmp(*self->GetNestedSignalState()) == 0) {
240 for (const auto& handler : other_handlers_) {
241 if (handler->Action(sig, info, context)) {
Dave Allison8be44cf2014-09-04 14:33:42 -0700242 // Restore the signal handlers, reinit the fault manager and return. Signal was
243 // handled.
Ian Rogersad11e7a2014-11-11 16:55:11 -0800244 for (size_t i = 0; i < num_handled_nested_signals; ++i) {
245 success = sigaction(handled_nested_signals[i], &oldactions[i], nullptr) == 0;
246 if (!success) {
247 PLOG(ERROR) << "Unable to restore signal handler";
248 }
249 }
Dave Allison8be44cf2014-09-04 14:33:42 -0700250 fault_manager.Init();
251 return;
Dave Allison0c2894b2014-08-29 12:06:16 -0700252 }
253 }
254 } else {
255 LOG(ERROR) << "Nested signal detected - original signal being reported";
Dave Allisonb373e092014-02-20 16:06:36 -0800256 }
Dave Allison0c2894b2014-08-29 12:06:16 -0700257
258 // Restore the signal handlers.
Ian Rogersad11e7a2014-11-11 16:55:11 -0800259 for (size_t i = 0; i < num_handled_nested_signals; ++i) {
260 success = sigaction(handled_nested_signals[i], &oldactions[i], nullptr) == 0;
261 if (!success) {
262 PLOG(ERROR) << "Unable to restore signal handler";
263 }
264 }
Dave Allisonb373e092014-02-20 16:06:36 -0800265 }
Dave Allisondfd3b472014-07-16 16:04:32 -0700266
Dave Allison0c2894b2014-08-29 12:06:16 -0700267 // Now put the fault manager back in place.
268 fault_manager.Init();
Dave Allisonf4b80bc2014-05-14 15:41:25 -0700269
Dave Allison8be44cf2014-09-04 14:33:42 -0700270 // Set a breakpoint in this function to catch unhandled signals.
271 art_sigsegv_fault();
Dave Allison0c2894b2014-08-29 12:06:16 -0700272
Dave Allison8be44cf2014-09-04 14:33:42 -0700273 // Pass this on to the next handler in the chain, or the default if none.
274 InvokeUserSignalHandler(sig, info, context);
Dave Allisonb373e092014-02-20 16:06:36 -0800275}
276
Mathieu Chartierc751fdc2014-03-30 15:25:44 -0700277void FaultManager::AddHandler(FaultHandler* handler, bool generated_code) {
Andreas Gampe928f72b2014-09-09 19:53:48 -0700278 DCHECK(initialized_);
Mathieu Chartierc751fdc2014-03-30 15:25:44 -0700279 if (generated_code) {
280 generated_code_handlers_.push_back(handler);
281 } else {
282 other_handlers_.push_back(handler);
283 }
284}
285
286void FaultManager::RemoveHandler(FaultHandler* handler) {
287 auto it = std::find(generated_code_handlers_.begin(), generated_code_handlers_.end(), handler);
288 if (it != generated_code_handlers_.end()) {
289 generated_code_handlers_.erase(it);
290 return;
291 }
292 auto it2 = std::find(other_handlers_.begin(), other_handlers_.end(), handler);
293 if (it2 != other_handlers_.end()) {
294 other_handlers_.erase(it);
295 return;
296 }
297 LOG(FATAL) << "Attempted to remove non existent handler " << handler;
298}
Dave Allisonb373e092014-02-20 16:06:36 -0800299
300// This function is called within the signal handler. It checks that
301// the mutator_lock is held (shared). No annotalysis is done.
Dave Allison69dfe512014-07-11 17:11:58 +0000302bool FaultManager::IsInGeneratedCode(siginfo_t* siginfo, void* context, bool check_dex_pc) {
Dave Allisonb373e092014-02-20 16:06:36 -0800303 // We can only be running Java code in the current thread if it
304 // is in Runnable state.
Dave Allison5cd33752014-04-15 15:57:58 -0700305 VLOG(signals) << "Checking for generated code";
Dave Allisonb373e092014-02-20 16:06:36 -0800306 Thread* thread = Thread::Current();
307 if (thread == nullptr) {
Dave Allison5cd33752014-04-15 15:57:58 -0700308 VLOG(signals) << "no current thread";
Dave Allisonb373e092014-02-20 16:06:36 -0800309 return false;
310 }
311
312 ThreadState state = thread->GetState();
313 if (state != kRunnable) {
Dave Allison5cd33752014-04-15 15:57:58 -0700314 VLOG(signals) << "not runnable";
Dave Allisonb373e092014-02-20 16:06:36 -0800315 return false;
316 }
317
318 // Current thread is runnable.
319 // Make sure it has the mutator lock.
320 if (!Locks::mutator_lock_->IsSharedHeld(thread)) {
Dave Allison5cd33752014-04-15 15:57:58 -0700321 VLOG(signals) << "no lock";
Dave Allisonb373e092014-02-20 16:06:36 -0800322 return false;
323 }
324
Mathieu Chartiere401d142015-04-22 13:56:20 -0700325 ArtMethod* method_obj = 0;
Dave Allisonb373e092014-02-20 16:06:36 -0800326 uintptr_t return_pc = 0;
Mathieu Chartierc751fdc2014-03-30 15:25:44 -0700327 uintptr_t sp = 0;
Dave Allisonb373e092014-02-20 16:06:36 -0800328
329 // Get the architecture specific method address and return address. These
Mathieu Chartierc751fdc2014-03-30 15:25:44 -0700330 // are in architecture specific files in arch/<arch>/fault_handler_<arch>.
Dave Allisondfd3b472014-07-16 16:04:32 -0700331 GetMethodAndReturnPcAndSp(siginfo, context, &method_obj, &return_pc, &sp);
Dave Allisonb373e092014-02-20 16:06:36 -0800332
333 // If we don't have a potential method, we're outta here.
Dave Allison5cd33752014-04-15 15:57:58 -0700334 VLOG(signals) << "potential method: " << method_obj;
Mathieu Chartiere401d142015-04-22 13:56:20 -0700335 // TODO: Check linear alloc and image.
Mathieu Chartierc751fdc2014-03-30 15:25:44 -0700336 if (method_obj == 0 || !IsAligned<kObjectAlignment>(method_obj)) {
Dave Allison5cd33752014-04-15 15:57:58 -0700337 VLOG(signals) << "no method";
Dave Allisonb373e092014-02-20 16:06:36 -0800338 return false;
339 }
340
341 // Verify that the potential method is indeed a method.
342 // TODO: check the GC maps to make sure it's an object.
Dave Allisonb373e092014-02-20 16:06:36 -0800343 // Check that the class pointer inside the object is not null and is aligned.
Mathieu Chartierc751fdc2014-03-30 15:25:44 -0700344 // TODO: Method might be not a heap address, and GetClass could fault.
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800345 // No read barrier because method_obj may not be a real object.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700346 mirror::Class* cls = method_obj->GetDeclaringClassNoBarrier();
Dave Allisonb373e092014-02-20 16:06:36 -0800347 if (cls == nullptr) {
Dave Allison5cd33752014-04-15 15:57:58 -0700348 VLOG(signals) << "not a class";
Dave Allisonb373e092014-02-20 16:06:36 -0800349 return false;
350 }
351 if (!IsAligned<kObjectAlignment>(cls)) {
Dave Allison5cd33752014-04-15 15:57:58 -0700352 VLOG(signals) << "not aligned";
Dave Allisonb373e092014-02-20 16:06:36 -0800353 return false;
354 }
355
356
357 if (!VerifyClassClass(cls)) {
Dave Allison5cd33752014-04-15 15:57:58 -0700358 VLOG(signals) << "not a class class";
Dave Allisonb373e092014-02-20 16:06:36 -0800359 return false;
360 }
361
Dave Allisonb373e092014-02-20 16:06:36 -0800362 // We can be certain that this is a method now. Check if we have a GC map
363 // at the return PC address.
Dave Allisonf9439142014-03-27 15:10:22 -0700364 if (true || kIsDebugBuild) {
Dave Allison5cd33752014-04-15 15:57:58 -0700365 VLOG(signals) << "looking for dex pc for return pc " << std::hex << return_pc;
Mathieu Chartiera7dd0382014-11-20 17:08:58 -0800366 const void* code = Runtime::Current()->GetInstrumentation()->GetQuickCodeFor(method_obj,
367 sizeof(void*));
Dave Allisonf9439142014-03-27 15:10:22 -0700368 uint32_t sought_offset = return_pc - reinterpret_cast<uintptr_t>(code);
Dave Allison5cd33752014-04-15 15:57:58 -0700369 VLOG(signals) << "pc offset: " << std::hex << sought_offset;
Dave Allisonf9439142014-03-27 15:10:22 -0700370 }
Mathieu Chartierc751fdc2014-03-30 15:25:44 -0700371 uint32_t dexpc = method_obj->ToDexPc(return_pc, false);
Dave Allison5cd33752014-04-15 15:57:58 -0700372 VLOG(signals) << "dexpc: " << dexpc;
Mathieu Chartierc751fdc2014-03-30 15:25:44 -0700373 return !check_dex_pc || dexpc != DexFile::kDexNoIndex;
374}
375
376FaultHandler::FaultHandler(FaultManager* manager) : manager_(manager) {
Dave Allisonb373e092014-02-20 16:06:36 -0800377}
378
379//
380// Null pointer fault handler
381//
Mathieu Chartierc751fdc2014-03-30 15:25:44 -0700382NullPointerHandler::NullPointerHandler(FaultManager* manager) : FaultHandler(manager) {
383 manager_->AddHandler(this, true);
Dave Allisonb373e092014-02-20 16:06:36 -0800384}
385
386//
387// Suspension fault handler
388//
Mathieu Chartierc751fdc2014-03-30 15:25:44 -0700389SuspensionHandler::SuspensionHandler(FaultManager* manager) : FaultHandler(manager) {
390 manager_->AddHandler(this, true);
Dave Allisonb373e092014-02-20 16:06:36 -0800391}
392
393//
394// Stack overflow fault handler
395//
Mathieu Chartierc751fdc2014-03-30 15:25:44 -0700396StackOverflowHandler::StackOverflowHandler(FaultManager* manager) : FaultHandler(manager) {
397 manager_->AddHandler(this, true);
Dave Allisonb373e092014-02-20 16:06:36 -0800398}
Mathieu Chartierc751fdc2014-03-30 15:25:44 -0700399
400//
401// Stack trace handler, used to help get a stack trace from SIGSEGV inside of compiled code.
402//
403JavaStackTraceHandler::JavaStackTraceHandler(FaultManager* manager) : FaultHandler(manager) {
404 manager_->AddHandler(this, false);
405}
406
407bool JavaStackTraceHandler::Action(int sig, siginfo_t* siginfo, void* context) {
408 // Make sure that we are in the generated code, but we may not have a dex pc.
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700409 UNUSED(sig);
Dave Allison8ce6b902014-08-26 11:07:58 -0700410#ifdef TEST_NESTED_SIGNAL
411 bool in_generated_code = true;
412#else
413 bool in_generated_code = manager_->IsInGeneratedCode(siginfo, context, false);
414#endif
415 if (in_generated_code) {
Mathieu Chartierc751fdc2014-03-30 15:25:44 -0700416 LOG(ERROR) << "Dumping java stack trace for crash in generated code";
Mathieu Chartiere401d142015-04-22 13:56:20 -0700417 ArtMethod* method = nullptr;
Mathieu Chartierc751fdc2014-03-30 15:25:44 -0700418 uintptr_t return_pc = 0;
419 uintptr_t sp = 0;
Mathieu Chartierc751fdc2014-03-30 15:25:44 -0700420 Thread* self = Thread::Current();
Dave Allison8ce6b902014-08-26 11:07:58 -0700421
Dave Allison0c2894b2014-08-29 12:06:16 -0700422 manager_->GetMethodAndReturnPcAndSp(siginfo, context, &method, &return_pc, &sp);
423 // Inside of generated code, sp[0] is the method, so sp is the frame.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700424 self->SetTopOfStack(reinterpret_cast<ArtMethod**>(sp));
Dave Allison8ce6b902014-08-26 11:07:58 -0700425#ifdef TEST_NESTED_SIGNAL
Dave Allison0c2894b2014-08-29 12:06:16 -0700426 // To test the nested signal handler we raise a signal here. This will cause the
427 // nested signal handler to be called and perform a longjmp back to the setjmp
428 // above.
429 abort();
Dave Allison8ce6b902014-08-26 11:07:58 -0700430#endif
Dave Allison0c2894b2014-08-29 12:06:16 -0700431 self->DumpJavaStack(LOG(ERROR));
Mathieu Chartierc751fdc2014-03-30 15:25:44 -0700432 }
Dave Allison8ce6b902014-08-26 11:07:58 -0700433
Mathieu Chartierc751fdc2014-03-30 15:25:44 -0700434 return false; // Return false since we want to propagate the fault to the main signal handler.
435}
436
Dave Allisonb373e092014-02-20 16:06:36 -0800437} // namespace art