Wrong description in globals.hpp
David Holmes
david.holmes at oracle.com
Tue Jun 26 00:08:11 PDT 2012
Hi Pierre,
On 22/06/2012 1:20 AM, Pierre Laporte wrote:
> It seems though that the information in globals.hpp is not completely
> true. A follower (@OlivierJaquemet) pointed that the
> description of MaxJavaStackTraceDepth is slightly wrong :
> "/Regarding options MaxJavaStackTraceDepth :
> * With Java > 1.6, value 0 really means 0. value -1 or any negative
> number must be specified to print all the stack (tested with 1.6.0_22,
> 1.7.0 on Windows)
> * With Java <= 1.5, value 0 means everything, JVM chokes on negative
> number (tested with 1.5.0_22 on Windows)hotspot-dev at openjdk.java.net
> <mailto:hotspot-dev at openjdk.java.net>/"
>
> As of jdk7u4, the description of this option in globals.hpp (line 2893)
> is still "Max. no. of lines in the stack trace for Java exceptions (0
> means all)". Can you update it with "Max. no. of lines in the stack
> trace for Java exceptions (-1 means all, 0 means nothing)" ?
I think you have stumbled onto a bug that was probably introduced when
some stacktrace handling improvements were added to JDK 6. In
java_lang_Throwable::fill_in_stack_trace we have:
int max_depth = MaxJavaStackTraceDepth;
...
int total_count = 0;
...
for (frame fr = thread->last_frame(); max_depth != total_count;) {
So if MaxJavaStackTraceDepth == 0 we never enter the loop; and if it is
negative we never skip out unless we reach the first frame (handled
inside the loop explicitly) or we overflow the integer count (not
likely). This is not the case in Java 5 as you note.
However MaxJavaStackTraceDepth is used in three other places in the VM:
- thread.cpp: JavaThread::print_stack_on treats <= 0 as 'all'
- forte.cpp: has three uses. Two treat < 0 as 'all', the other treats
<=0 as zero! (it has no "all" setting!)
- jvmtiEnvBase.cpp: JvmtiEnvBase::get_owned_monitors treats < 0 as 'all'
So we have some code bugs here instead of, or as well as, a
documentation bug.
David Holmes
------------
More information about the hotspot-dev
mailing list