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

David Holmes David.Holmes at oracle.com
Wed Jul 6 20:20:03 PDT 2011


Krystal Mok said the following on 07/06/11 18:53:
> 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 
> ThreadStackSize.
> 
> 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.

-Xss is an officially supported option for the java launcher. 
-XX:ThreadStackSize is an unsupported Hotspot JVM option. The launcher 
uses this option to implement its processing of -Xss.

> 2. Is it better to remove the special handling of -Xss in the launcher, 
> in AddOption(char *str, void *info):

No. Simply don't use -XX:ThreadStackSize when using the launcher - that 
is what -Xss is for.

David
-----


> $ 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)
> 
> Regards,
> Kris Mok
> 
> [0]: http://mail.openjdk.java.net/pipermail/hotspot-dev/2011-June/004272.html
> [1]: https://gist.github.com/1066792


More information about the hotspot-dev mailing list