255 // Catching SIGBUS here prevents the implicit SIGBUS null check below from
256 // being called, so only do so if the implicit null check is not necessary.
257 } else if (sig == SIGBUS && !MacroAssembler::uses_implicit_null_check(info->si_addr)) {
258 #else
259 } else if (sig == SIGBUS /* && info->si_code == BUS_OBJERR */) {
260 #endif
261 // BugId 4454115: A read from a MappedByteBuffer can fault
262 // here if the underlying file has been truncated.
263 // Do not crash the VM in such a case.
264 CodeBlob* cb = CodeCache::find_blob(pc);
265 nmethod* nm = (cb != nullptr) ? cb->as_nmethod_or_null() : nullptr;
266 bool is_unsafe_memory_access = (thread->doing_unsafe_access() && UnsafeMemoryAccess::contains_pc(pc));
267 if ((nm != nullptr && nm->has_unsafe_access()) || is_unsafe_memory_access) {
268 address next_pc = pc + NativeCall::instruction_size;
269 if (is_unsafe_memory_access) {
270 next_pc = UnsafeMemoryAccess::page_error_continue_pc(pc);
271 }
272 stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
273 }
274 } else if (sig == SIGILL && nativeInstruction_at(pc)->is_stop()) {
275 // Pull a pointer to the error message out of the instruction
276 // stream.
277 const uint64_t *detail_msg_ptr
278 = (uint64_t*)(pc + NativeInstruction::instruction_size);
279 const char *detail_msg = (const char *)*detail_msg_ptr;
280 const char *msg = "stop";
281 if (TraceTraps) {
282 tty->print_cr("trap: %s: (SIGILL)", msg);
283 }
284
285 // End life with a fatal error, message and detail message and the context.
286 // Note: no need to do any post-processing here (e.g. signal chaining)
287 VMError::report_and_die(thread, uc, nullptr, 0, msg, "%s", detail_msg);
288 ShouldNotReachHere();
289
290 } else if (sig == SIGFPE &&
291 (info->si_code == FPE_INTDIV || info->si_code == FPE_FLTDIV)) {
292 stub =
293 SharedRuntime::
294 continuation_for_implicit_exception(thread,
295 pc,
296 SharedRuntime::
297 IMPLICIT_DIVIDE_BY_ZERO);
298 } else if ((sig == SIGSEGV || sig == SIGBUS) &&
299 MacroAssembler::uses_implicit_null_check(info->si_addr)) {
|
255 // Catching SIGBUS here prevents the implicit SIGBUS null check below from
256 // being called, so only do so if the implicit null check is not necessary.
257 } else if (sig == SIGBUS && !MacroAssembler::uses_implicit_null_check(info->si_addr)) {
258 #else
259 } else if (sig == SIGBUS /* && info->si_code == BUS_OBJERR */) {
260 #endif
261 // BugId 4454115: A read from a MappedByteBuffer can fault
262 // here if the underlying file has been truncated.
263 // Do not crash the VM in such a case.
264 CodeBlob* cb = CodeCache::find_blob(pc);
265 nmethod* nm = (cb != nullptr) ? cb->as_nmethod_or_null() : nullptr;
266 bool is_unsafe_memory_access = (thread->doing_unsafe_access() && UnsafeMemoryAccess::contains_pc(pc));
267 if ((nm != nullptr && nm->has_unsafe_access()) || is_unsafe_memory_access) {
268 address next_pc = pc + NativeCall::instruction_size;
269 if (is_unsafe_memory_access) {
270 next_pc = UnsafeMemoryAccess::page_error_continue_pc(pc);
271 }
272 stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
273 }
274 } else if (sig == SIGILL && nativeInstruction_at(pc)->is_stop()) {
275 // A pointer to the message will have been placed in x0
276 const char *detail_msg = (const char *)(uc->uc_mcontext->DU3_PREFIX(ss,x[0]));
277 const char *msg = "stop";
278 if (TraceTraps) {
279 tty->print_cr("trap: %s: (SIGILL)", msg);
280 }
281
282 // End life with a fatal error, message and detail message and the context.
283 // Note: no need to do any post-processing here (e.g. signal chaining)
284 VMError::report_and_die(thread, uc, nullptr, 0, msg, "%s", detail_msg);
285 ShouldNotReachHere();
286
287 } else if (sig == SIGFPE &&
288 (info->si_code == FPE_INTDIV || info->si_code == FPE_FLTDIV)) {
289 stub =
290 SharedRuntime::
291 continuation_for_implicit_exception(thread,
292 pc,
293 SharedRuntime::
294 IMPLICIT_DIVIDE_BY_ZERO);
295 } else if ((sig == SIGSEGV || sig == SIGBUS) &&
296 MacroAssembler::uses_implicit_null_check(info->si_addr)) {
|