author | alanb |
Sat, 09 Nov 2019 09:13:04 +0000 | |
changeset 58999 | 6bc29ebe053e |
permissions | -rw-r--r-- |
58999
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
1 |
/* |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, Red Hat, Inc. and/or its affiliates. |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
4 |
* |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
8 |
* |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
13 |
* accompanied this code). |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
14 |
* |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
18 |
* |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
21 |
* questions. |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
22 |
*/ |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
23 |
|
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
24 |
/** |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
25 |
* @test |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
26 |
* @bug 8216472 |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
27 |
* @summary native call in WindowsSelectorImpl.SubSelector.poll can use |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
28 |
* more stack space than available in a shadow zone, this can cause |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
29 |
* a crash if selector is called from a deep recursive java call |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
30 |
* @requires (os.family == "windows") |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
31 |
*/ |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
32 |
|
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
33 |
import java.nio.channels.Selector; |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
34 |
|
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
35 |
public class StackOverflowTest { |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
36 |
|
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
37 |
public static void main(String[] args) throws Exception { |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
38 |
try (var sel = Selector.open()) { |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
39 |
recursiveSelect(sel); |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
40 |
} catch (StackOverflowError e) { |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
41 |
// ignore SOE from java calls |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
42 |
} |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
43 |
} |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
44 |
|
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
45 |
static void recursiveSelect(Selector sel) throws Exception { |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
46 |
sel.selectNow(); |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
47 |
recursiveSelect(sel); |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
48 |
} |
6bc29ebe053e
8216472: (se) Stack overflow during selection operation leads to crash (win)
alanb
parents:
diff
changeset
|
49 |
} |