This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: FYI: interpreter fixlet
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 24 Jun 2005 15:57:48 -0600
- Subject: Patch: FYI: interpreter fixlet
- Reply-to: tromey at redhat dot com
At FOSDEM, Jeroen gave me a simple class loading test case that takes
a class and modifies its contents, mutating the bytes one by one.
This is a robustness test for the class reader; ours fails in a
surprisingly large number of ways.
This patch is the first fix. We don't want to trust that the entries
in the line number table are correct. So, we should ignore obviously
corrupt ones.
I'm checking this in on the trunk.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* interpret.cc (compile): Handle case where table entry is
outside of PC range.
Index: interpret.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/interpret.cc,v
retrieving revision 1.50
diff -u -r1.50 interpret.cc
--- interpret.cc 22 Apr 2005 19:02:40 -0000 1.50
+++ interpret.cc 24 Jun 2005 21:59:44 -0000
@@ -1,6 +1,6 @@
// interpret.cc - Code for the interpreter
-/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation
+/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation
This file is part of libgcj.
@@ -763,6 +763,10 @@
for (int i = 0; i < line_table_len; i++)
{
int byte_pc = line_table[i].bytecode_pc;
+ // It isn't worth throwing an exception if this table is
+ // corrupted, but at the same time we don't want a crash.
+ if (byte_pc < 0 || byte_pc >= code_length)
+ byte_pc = 0;
line_table[i].pc = &insns[pc_mapping[byte_pc]];
}