This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: FYI: verifier fix
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 03 Dec 2001 23:41:02 -0700
- Subject: Patch: FYI: verifier fix
- Reply-to: tromey at redhat dot com
I'm checking this in.
This fixes a subtle bug in the verifier which caused memory corruption
and then a crash in certain circumstances.
Also, it moves some the (still commented out) verifier invocation to
the correct place. Now we verify after all the methods have been
read. This is important because the Exception information is read
after the method's body -- with the previous code we were not
verifying using the correct exception table.
Debugging tonight revealed a major bug in the verifier relating to how
control flow is handled. I'll try to fix it soon. I'm not exactly
sure how to decide when we should enable the verifier, but I know we
aren't there yet.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* defineclass.cc (handleMethodsEnd): Invoke verifier here...
(handleCodeAttribute): ... not here.
* verify.cc (_Jv_BytecodeVerifier::state::state): Use `copy', not
structure assignment.
Index: defineclass.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/defineclass.cc,v
retrieving revision 1.23
diff -u -r1.23 defineclass.cc
--- defineclass.cc 2001/11/26 06:40:04 1.23
+++ defineclass.cc 2001/12/04 06:32:03
@@ -500,10 +500,10 @@
check_tag (name_index, JV_CONSTANT_Utf8);
prepare_pool_entry (descriptor_index, JV_CONSTANT_Utf8);
-
+
handleMethod (i, access_flags, name_index,
descriptor_index);
-
+
for (int j = 0; j < attributes_count; j++)
{
read_one_method_attribute (i);
@@ -1282,10 +1282,6 @@
code_length);
def->interpreted_methods[method_index] = method;
-
- // FIXME: Shouldn't this be done after loading completes?
-// if (verify)
-// _Jv_VerifyMethod (method);
}
void _Jv_ClassReader::handleExceptionTableEntry
@@ -1332,9 +1328,17 @@
{
if (def->interpreted_methods[i] == 0)
throw_class_format_error ("method with no code");
+
+ if (verify)
+ {
+ _Jv_InterpMethod *m;
+ m = (reinterpret_cast<_Jv_InterpMethod *>
+ (def->interpreted_methods[i]));
+ // FIXME: enable once verifier is more fully tested.
+ // _Jv_VerifyMethod (m);
+ }
}
}
-
}
void _Jv_ClassReader::throw_class_format_error (char *msg)
Index: verify.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/verify.cc,v
retrieving revision 1.17
diff -u -r1.17 verify.cc
--- verify.cc 2001/11/25 19:48:19 1.17
+++ verify.cc 2001/12/04 06:32:05
@@ -697,12 +697,12 @@
subroutine = 0;
}
- state (const state *copy, int max_stack, int max_locals)
+ state (const state *orig, int max_stack, int max_locals)
{
stack = new type[max_stack];
locals = new type[max_locals];
local_changed = (bool *) _Jv_Malloc (sizeof (bool) * max_locals);
- *this = *copy;
+ copy (orig, max_stack, max_locals);
next = INVALID;
}