Inconsistency between -Xss and -XX:ThreadStackSize in the java launcher

Krystal Mok rednaxelafx at
Wed Jul 6 01:53:46 PDT 2011


After replying to a question on the difference of -Xss and
-XX:ThreadStackSize on this list [0], I found that the java launcher in both
JDK6 and JDK7 handles those two flags inconsistently.
-Xss and -XX:ThreadStackSize, whichever comes later, sets the value of the
flag ThreadStackSize. That's in HotSpot VM's argument handling, and there's
no problem with that.

But in the java launcher, if -Xss (or -ss) were passed on the command line,
it gets picked up directly by the launcher and is used later to create the
"main" Java thread, without asking the VM for the preferred thread stack
size. That where inconsistency comes from:
 if -Xss is given after -XX:ThreadStackSize, then things are still good;
 otherwise, the "main" Java thread would have a stack size specified by -Xss
where as other Java threads' stack size would still follow that of

It's not straightforward to verify this behavior, because there's no public
API in the JDK that tells the size of the thread stack. So to see the size
of the stack, we could:
(1) Write a function in native code to get the thread stack size, and call
it via JNI;
(2) Use the Serviceability Agent to get the thread stack stack in question;
(3) Make the VM crash and read the crash log... ( ;-)

I was too lazy to write (1), thought about (2) but decided to use (3). I
posted the test code and the result on Github [1].

Now, I'd like to ask:
1. Why did the java launcher need to pick up -Xss directly? There should
have been some historic reason for it.
2. Is it better to remove the special handling of -Xss in the launcher, in
AddOption(char *str, void *info):

$ hg diff
diff -r 38fa55e5e792 src/share/tools/launcher/java.c
--- a/src/share/tools/launcher/java.c Thu Jun 16 13:46:55 2011 -0700
+++ b/src/share/tools/launcher/java.c Wed Jul 06 16:51:46 2011 +0800
@@ -866,13 +866,6 @@
     options[numOptions].optionString = str;
     options[numOptions++].extraInfo = info;
-    if (strncmp(str, "-Xss", 4) == 0) {
-      jlong tmp;
-      if (parse_stack_size(str + 4, &tmp)) {
-        threadStackSize = tmp;
-      }
-    }

(This diff is made against current tip of jdk7/hotspot-rt)

Kris Mok

-------------- next part --------------
An HTML attachment was scrubbed...

More information about the hotspot-dev mailing list