2273N/A * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 1176N/A * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc. 1010N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1010N/A * This code is free software; you can redistribute it and/or modify it 1010N/A * under the terms of the GNU General Public License version 2 only, as 1010N/A * published by the Free Software Foundation. 1010N/A * This code is distributed in the hope that it will be useful, but WITHOUT 1010N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1010N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1010N/A * version 2 for more details (a copy is included in the LICENSE file that 1010N/A * You should have received a copy of the GNU General Public License version 1010N/A * 2 along with this work; if not, write to the Free Software Foundation, 1010N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1010N/A // The only thing that calls this is the stack printing code in 1010N/A // - Step 110 (printing stack bounds) uses the sp in the frame 1010N/A // to determine the amount of free space on the stack. We 1010N/A // set the sp to a close approximation of the real value in 1010N/A // order to allow this step to complete. 1010N/A // - Step 120 (printing native stack) tries to walk the stack. 1010N/A // The frame we create has a NULL pc, which is ignored as an 1010N/A // Must never look like an address returned by reserve_memory, 1010N/A // even in its subfields (as defined by the CPU immediate fields, 1010N/A // if the CPU splits constants across multiple instructions). 1010N/A // On SPARC, 0 != %hi(any real address), because there is no 1010N/A // allocation in the first 1Kb of the virtual address space. 1010N/A // This is the value for x86; works pretty well for PPC too. 1010N/A // install then restore certain signal handler (e.g. to temporarily 1010N/A // block SIGPIPE, or have a SIGILL handler when detecting CPU 1010N/A // type). When that happens, JVM_handle_linux_signal() might be 1010N/A // libjsig is not preloaded, try handle signals that do not require 1010N/A // allow chained handler to go first 1010N/A // Handle ALL stack overflow variations here 1010N/A // check if fault address is within thread stack 1010N/A // Accessing stack address below sp may cause SEGV if 1010N/A // current thread has MAP_GROWSDOWN stack. This should 1010N/A // only happen when current thread was created by user 1010N/A // code with MAP_GROWSDOWN flag and then attached to VM. 1010N/A /*if (thread->thread_state() == _thread_in_Java) { 1010N/A // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC 1010N/A // kicks in and the heap gets shrunk before the field access. 1010N/A /*if (sig == SIGSEGV || sig == SIGBUS) { 1010N/A address addr = JNI_FastGetField::find_slowcase_pc(pc); 1010N/A // Check to see if we caught the safepoint code in the process 1010N/A // of write protecting the memory serialization page. It write 1010N/A // enables the page immediately after protecting it so we can 1010N/A // just return to retry the write. 1010N/A // Block current thread until permission is restored. 1010N/A // caller wants another chance, so give it to him 1010N/A "\n# /--------------------\\" 1010N/A "\n# | segmentation fault |" 1010N/A "\n# \\---\\ /--------------/" 1010N/A const char *
fmt =
"caught unhandled signal %d";
1010N/A/////////////////////////////////////////////////////////////////////////////// 1010N/A // Only enable glibc guard pages for non-Java threads 1010N/A // (Java threads have HotSpot guard pages) 1010N/A // The block of memory returned by pthread_attr_getstack() includes 1010N/A // guard pages where present. We need to trim these off. 1010N/A // IA64 has two stacks sharing the same area of memory, a normal 1010N/A // stack growing downwards and a register stack growing upwards. 1010N/A // Guard pages, if present, are in the centre. This code splits 1010N/A // the stack in two even without guard pages, though in theory 1010N/A // there's nothing to stop us allocating more to the normal stack 1010N/A // or more to the register stack if one or the other were found 1010N/A // The initial thread has a growable stack, and the size reported 1010N/A // by pthread_attr_getstack is the maximum size it could possibly 1010N/A // be given what currently mapped. This can be huge, so we cap it. 1010N/A // stack size includes normal stack and HotSpot guard pages 1010N/A///////////////////////////////////////////////////////////////////////////// 1010N/A// helper functions for fatal error handler 1010N/A///////////////////////////////////////////////////////////////////////////// 1010N/A// You probably want to disassemble these monkeys to check they're ok. 1010N/A///////////////////////////////////////////////////////////////////////////// 1010N/A// Implementations of atomic operations not supported by processors.