looking for help to identify a possible jvm bug

7 views
Skip to first unread message

Jochen Theodorou

unread,
Jun 23, 2009, 1:11:53 PM6/23/09
to jvm-la...@googlegroups.com
Hi all,

in Groovy we have now the second case of someone discovering a bug that
seems to be not a groovy bug. It seems to happen only on windows with a
64bit environment. This makes it difficult to reproduce, since not many
people bother with that it seems. So I am asking here for people to
confirm the problem and maybe helping me to reducing the sample code.

Anyway, the bug is reported with several 64bit VMs.. namely 1.6.0u13 and
1.6.0u11 or 12. A 32bit VM and the code works without problems. starting
the program with -Xint and the problem goes away for 64bit too. Also
Groovy 1.6.3 is required for this example, but I think any 1.6 Groovy
will do... maybe even before. The sample is a groovy program:

> def binstr = { v, n=4 ->
> def s = ("0"*n + Integer.toBinaryString(v))
> return s.substring(s.size()-n)
> }
>
> def uniqcols = { a, b, cols=4 ->
> def l = [] as HashSet
> 0.upto(cols-1) { bitno ->
> def bitmask = 1<<bitno
> switch (bitno) {
> case 0 : valu = ((a&bitmask) << 1) | (b&bitmask)
> break
> default : valu = ((a&bitmask) >> (bitno-1)) | ((b&bitmask) >> bitno)
> break
> }
> l << valu // add value to set
> }
> // println l
> return l.size()
> }
>
> 3.upto(8) { n ->
> def lastval = 2**n - 1
> def spacefill = " "*(n+1)
> def fmtstr = "%${n}d "
> println "${fmtstr}"
>
> def File file = new File("k2m${n}.txt")
> def PrintWriter writer = file.newPrintWriter()
>
> // heading
> writer.print spacefill
> 0.upto(lastval) { i -> writer.print "${binstr(i,n)} " };
> writer.println ""
>
> // data lines
> 0.upto(lastval) { i ->
> writer.print "${binstr(i,n)} "
> 0.upto(lastval) { j ->
> writer.print String.format(fmtstr, n-uniqcols(i,j,n))
> }
> writer.println ""
> }
> writer.close() // files 3 to 5 empty without this!
> }


what fails is the String.format call, that deep down in Groovy will call
a System.arraycopy, which then fails with a ArrayOutOfBoundsException,
without any further explanation about what happened. A clear error
message would have helped to identify the problem already, but VM error
messages have never been very detailed.

So anyway how can assist here?

bye blackdrag

--
Jochen "blackdrag" Theodorou
The Groovy Project Tech Lead (http://groovy.codehaus.org)
http://blackdragsview.blogspot.com/

David Schlosnagle

unread,
Jun 23, 2009, 10:02:03 PM6/23/09
to jvm-la...@googlegroups.com
Jochen,

Since it works with -Xint, it sounds like it could be a problem with the generated compiled code. You may want to try reproduce with -XX:+PrintCompilation and some other flags [1] to gather additional information. I don't have access to a Windows 64-bit box right now, but I wasn't able to recreate with 1.6.u13 64-bit on Mac OS X/Intel.

    set JAVA_OPTS="-Xcomp -Xbatch -XX:+PrintCompilation -XX:+ShowMessageBoxOnError"
    groovy test.groovy

[1]: http://blogs.sun.com/watt/resource/jvm-options-list.html

- David Schlosnagle

Jochen Theodorou

unread,
Jun 24, 2009, 7:36:08 AM6/24/09
to jvm-la...@googlegroups.com
David Schlosnagle schrieb:

> Jochen,
>
> Since it works with -Xint, it sounds like it could be a problem with the
> generated compiled code. You may want to try reproduce with
> -XX:+PrintCompilation and some other flags [1] to gather additional
> information. I don't have access to a Windows 64-bit box right now, but
> I wasn't able to recreate with 1.6.u13 64-bit on Mac OS X/Intel.

yeah, the MAC version is confirmed to be working. The linux version of
the VM is working too. Btw, it turned out only the String.format call is
enough to trigger the problem.

> set JAVA_OPTS="-Xcomp -Xbatch -XX:+PrintCompilation
> -XX:+ShowMessageBoxOnError"
> groovy test.groovy
>
> [1]: http://blogs.sun.com/watt/resource/jvm-options-list.html

will try

Jochen Theodorou

unread,
Jun 24, 2009, 12:27:17 PM6/24/09
to jvm-la...@googlegroups.com
David Schlosnagle schrieb:

> Jochen,
>
> Since it works with -Xint, it sounds like it could be a problem with the
> generated compiled code. You may want to try reproduce with
> -XX:+PrintCompilation and some other flags [1] to gather additional
> information. I don't have access to a Windows 64-bit box right now, but
> I wasn't able to recreate with 1.6.u13 64-bit on Mac OS X/Intel.
>
> set JAVA_OPTS="-Xcomp -Xbatch -XX:+PrintCompilation
> -XX:+ShowMessageBoxOnError"
> groovy test.groovy
>
> [1]: http://blogs.sun.com/watt/resource/jvm-options-list.html

System.arraycopy will of course not show up, the area around the calling
method (org.codehaus.groovy.reflection.ParameterTypes::fitToVargs) looks
like this:

> 3148 b org.codehaus.groovy.classgen.BytecodeHelper::box (69 bytes)
> 3149 b org.codehaus.groovy.reflection.ParameterTypes::fitToVargs (202 bytes)
> 3149 made not entrant org.codehaus.groovy.reflection.ParameterTypes::fitToVargs (202 bytes)
> 3150 b java.lang.reflect.Array::newInstance (6 bytes)
> 2309 made not entrant org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite::createStaticMetaMethodSite (84 bytes)
> 3151 !b org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite::invoke (20 bytes)
> 3152 b org.codehaus.groovy.reflection.ParameterTypes::fitToVargs (202 bytes)
> 3153 b java.lang.ArrayIndexOutOfBoundsException::<init> (5 bytes)

can you make something out of this? I can send you the full list too...

bye Jochen

Reply all
Reply to author
Forward
0 new messages