This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
please try this Java test program
- To: java at gcc dot gnu dot org
- Subject: please try this Java test program
- From: Per Bothner <per at bothner dot com>
- Date: 29 Apr 2001 01:07:15 -0700
I've tracked down the crash in Jigsaw to a mis-compilation of
Properties.java. If you are running on Linux, I would be interested
if you could try compiling and running this program against the 3.0 branch:
$ gcj -o proptest --main=PropTest PropTest.java -g
$ ./proptest
import java.io.ByteArrayInputStream;
import java.util.Properties;
public class PropTest
{
static String data = "#Updated by Install\n"
+ "#Fri Apr 20 13:18:30 PDT 2001\n"
+ "org.w3c.jigsaw.http.socket.SocketClientFactory.maxClients=30\n"
+ "org.w3c.jigsaw.request.timeout=3000000\n";
public static void main(String[] args) throws java.io.IOException
{
byte[] buf = new byte[data.length()];
for (int i = buf.length; --i >= 0; )
buf[i] = (byte) data.charAt(i);
ByteArrayInputStream in = new ByteArrayInputStream(buf);
Properties props = new Properties();
props.load(in);
}
}
I get the following stack trace:
Exception in thread "main" java.lang.NegativeArraySizeException
at 0x401a142b: java.lang.Throwable.Throwable() (/home/bothner/GNU/install-gcc3/lib/libgcj.so.2)
at 0x4019667b: java.lang.Exception.Exception() (/home/bothner/GNU/install-gcc3/lib/libgcj.so.2)
at 0x4019ac7b: java.lang.RuntimeException.RuntimeException() (/home/bothner/GNU/install-gcc3/lib/libgcj.so.2)
at 0x4019a25b: java.lang.NegativeArraySizeException.NegativeArraySizeException() (/home/bothner/GNU/install-gcc3/lib/libgcj.so.2)
at 0x40168bbe: _Jv_NewPrimArray (/home/bothner/GNU/install-gcc3/lib/libgcj.so.2)
at 0x4019cb55: java.lang.StringBuffer.StringBuffer(int) (/home/bothner/GNU/install-gcc3/lib/libgcj.so.2)
at 0x401e1687: java.util.Properties.load(java.io.InputStream) (/home/bothner/GNU/install-gcc3/lib/libgcj.so.2)
at 0x08048e10: PropTest::main(JArray<java::lang::String*>*) (/home/bothner/PropTest.java:17)
at 0x4017f90b: gnu.gcj.runtime.FirstThread.run() (/home/bothner/GNU/install-gcc3/lib/libgcj.so.2)
at 0x4018aa6b: java.lang.Thread.run_(java.lang.Object) (/home/bothner/GNU/install-gcc3/lib/libgcj.so.2)
at 0x4029c435: _Jv_ThreadSetPriority(_Jv_Thread_t, int) (/home/bothner/GNU/install-gcc3/lib/libgcj.so.2)
at 0x4044761c: GC_start_routine (/home/bothner/GNU/install-gcc3/lib/libgcjgc.so.1)
at 0x40461848: pthread_detach (/lib/libpthread.so.0)
at 0x4056292a: __clone (/lib/libc.so.6)
I tracked it down to a mis-compilation of a conditional jump, which
jumps one instruction too early. Specifically, it jumps from the
continue at line 140 of Properties.java to line 130 - almost. It
actually jumps one instruction too far - to the *last* instruction
of the previous call, specifically the instruction that adjusts the
stack after the call. Thus we end up we executing a bogus
instruction incrementing the stack pointer, which causes the
crash soon after.
I don't think I'm qualified to track this down, but I need other
people to see if they experience this bug.
--
--Per Bothner
per@bothner.com http://www.bothner.com/~per/