Java crashes in SocketOutputStream.socketWrite0 from libnet.so
Environment
- JBoss Enterprise Application Platform (EAP)
- Java
Issue
- JBoss/Java crashed in SocketOutputStream.socketWrite0 from libnet.so from a segmentation fault. There was no
hs_errfile generated to provide information on this crash. We captured a core from the crash instead and its backtrace indicated the following crashpoint:
Thread 1 (Thread 0x7fe1053d3700 (LWP 3936)):
#0 0x00007fe15503c5cd in Java_java_net_SocketOutputStream_socketWrite0 () from /opt/jboss/java/jdk1.6.0_25/jre/lib/amd64/libnet.so
Resolution
- Increase the
StackShadowPagesJVM setting so that more stack space is reserved for native code:
-XX:StackShadowPages=20
- Note that will leave less stack for java level code and so the entire thread stack (
-Xss) may need to be increased so that the amount of stack available to java level code is not decreased as a consequence.
Root Cause
- Per the following Content from bugs.sun.com is not included.Oracle JDK bug report, socketWrite had a buffer increase, which increased its native stack usage. Java code has to share the stack with native code such as socketWrite. A portion of that stack will be reserved specifically for native code per the JVM's
StackShadowPagessetting. The defaultStackShadowPagessetting no longer reserves enough stack for socketWrite's buffer size so if java level code recursion uses the rest of the stack except theStackShadowPagesreserved space, the socketWrite can crash. A StackOverflow in this native code will produce nohs_errfile.
Diagnostic Steps
- Troubleshoot with a core dump and additional steps per Java application down due to JVM crash
Components
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.