RFR(XS): 8073754: Zero/PPC: StackOverflowError during build in javadoc processing.
Severin Gehwolf
sgehwolf at redhat.com
Thu Jul 30 16:05:57 UTC 2015
On Thu, 2015-07-30 at 16:52 +0200, Severin Gehwolf wrote:
> > >> If a normal thread doesn't honor the -XX:ThreadStackSize settings I'd
> > >> consider that a bug and fix that one first.
> > >
> > > By fixing it you mean in jdk or hotspot code? Any suggestions?
> > >
> >
> > I mean in the hostspot code. But of coarse only if the above tests
> > show that the settings are not honored by the VM.
>
> OK.
So I did more experimentation with this and here is what I found. Any
JVM with -Xint fall back to the bigger of os::Linux::min_stack_allowed
as set in src/os_cpu/linux_$CPU/vm/os_linux_$CPU.cpp and the following
calculation coming from os::init_2 for the reproducer in [1]:
MAX2(os::Linux::min_stack_allowed,
(size_t)(StackYellowPages+StackRedPages+StackShadowPages) * Linux::page_size() +
(2*BytesPerWord COMPILER2_PRESENT(+1)) * Linux::vm_default_page_size());
It can be fairly easy reproduced with:
http://cr.openjdk.java.net/~sgehwolf/webrevs/JDK-8073754/ZeroStackOverflowTest.java
The following produces a stack overflow for me on x86_64:
/path/to/java -Xint ZeroStackOverflowTest 1280
If I change this to:
/path/to/java -Xint -XX:ThreadStackSize=2028 ZeroStackOverflowTest 1280
nothing changes. I.e. the stack overflow still happens at ~1266'th call.
In fact, the JVM uses a thread stack size setting of 228k (the result of
the calculation in os::init_2 which is bigger than the original set
value of 64k in src/os_cpu/linux_x86/vm/os_linux_x86.cpp).
If I build a JDK with this patch:
diff --git a/src/os_cpu/linux_x86/vm/os_linux_x86.cpp b/src/os_cpu/linux_x86/vm/os_linux_x86.cpp
--- a/src/os_cpu/linux_x86/vm/os_linux_x86.cpp
+++ b/src/os_cpu/linux_x86/vm/os_linux_x86.cpp
@@ -618,7 +618,7 @@
// thread stack
#ifdef AMD64
-size_t os::Linux::min_stack_allowed = 64 * K;
+size_t os::Linux::min_stack_allowed = 512 * K;
#else
size_t os::Linux::min_stack_allowed = (48 DEBUG_ONLY(+4))*K;
#endif // AMD64
Then run the reproducer again:
/path/to/java -Xint ZeroStackOverflowTest 1280
It no longer stack-overflows.
Something similar happens for me with a Zero JVM (which is always
interpreted only).
The JIT's seem to be doing something more and I wasn't able to reproduce
it for them.
Cheers,
Severin
[1] http://cr.openjdk.java.net/~sgehwolf/webrevs/JDK-8073754/ZeroStackOverflowTest.java
More information about the hotspot-dev
mailing list