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