1 /*
2 * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
3 * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
156
157 JavaThread* thread = NULL;
158 VMThread* vmthread = NULL;
159 if (os::Linux::signal_handlers_are_installed) {
160 if (t != NULL ){
161 if(t->is_Java_thread()) {
162 thread = (JavaThread*)t;
163 }
164 else if(t->is_VM_thread()){
165 vmthread = (VMThread *)t;
166 }
167 }
168 }
169
170 if (info != NULL && thread != NULL) {
171 // Handle ALL stack overflow variations here
172 if (sig == SIGSEGV) {
173 address addr = (address) info->si_addr;
174
175 // check if fault address is within thread stack
176 if (thread->on_local_stack(addr)) {
177 // stack overflow
178 if (thread->in_stack_yellow_reserved_zone(addr)) {
179 thread->disable_stack_yellow_reserved_zone();
180 ShouldNotCallThis();
181 }
182 else if (thread->in_stack_red_zone(addr)) {
183 thread->disable_stack_red_zone();
184 ShouldNotCallThis();
185 }
186 else {
187 // Accessing stack address below sp may cause SEGV if
188 // current thread has MAP_GROWSDOWN stack. This should
189 // only happen when current thread was created by user
190 // code with MAP_GROWSDOWN flag and then attached to VM.
191 // See notes in os_linux.cpp.
192 if (thread->osthread()->expanding_stack() == 0) {
193 thread->osthread()->set_expanding_stack();
194 if (os::Linux::manually_expand_stack(thread, addr)) {
195 thread->osthread()->clear_expanding_stack();
196 return true;
|
1 /*
2 * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
3 * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
156
157 JavaThread* thread = NULL;
158 VMThread* vmthread = NULL;
159 if (os::Linux::signal_handlers_are_installed) {
160 if (t != NULL ){
161 if(t->is_Java_thread()) {
162 thread = (JavaThread*)t;
163 }
164 else if(t->is_VM_thread()){
165 vmthread = (VMThread *)t;
166 }
167 }
168 }
169
170 if (info != NULL && thread != NULL) {
171 // Handle ALL stack overflow variations here
172 if (sig == SIGSEGV) {
173 address addr = (address) info->si_addr;
174
175 // check if fault address is within thread stack
176 if (thread->is_in_full_stack(addr)) {
177 // stack overflow
178 if (thread->in_stack_yellow_reserved_zone(addr)) {
179 thread->disable_stack_yellow_reserved_zone();
180 ShouldNotCallThis();
181 }
182 else if (thread->in_stack_red_zone(addr)) {
183 thread->disable_stack_red_zone();
184 ShouldNotCallThis();
185 }
186 else {
187 // Accessing stack address below sp may cause SEGV if
188 // current thread has MAP_GROWSDOWN stack. This should
189 // only happen when current thread was created by user
190 // code with MAP_GROWSDOWN flag and then attached to VM.
191 // See notes in os_linux.cpp.
192 if (thread->osthread()->expanding_stack() == 0) {
193 thread->osthread()->set_expanding_stack();
194 if (os::Linux::manually_expand_stack(thread, addr)) {
195 thread->osthread()->clear_expanding_stack();
196 return true;
|