harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r447080 - in /incubator/harmony/enhanced/drlvm/trunk/vm/vmcore: include/Class.h src/class_support/Class_File_Loader.cpp
Date Sun, 17 Sep 2006 15:26:53 GMT
Author: geirm
Date: Sun Sep 17 08:26:53 2006
New Revision: 447080

URL: http://svn.apache.org/viewvc?view=rev&rev=447080
Log:
HARMONY-1442

While TI is on, VM crashes when it attempts to define class which contains
method with absent local variable table information through JNI DefineClass.

When JVMTI is off, the local variable table of a class is not parsed, just skipped. When JVMTI
is on, the local 
variable table was parsed just fine. But the ambigous interface treated NULL returned by the
parsing function as an 
error, regardless of whether the local variable table was incorrect or just absent. Usually
local variable table is 
present, but classes are allowed not to have it. So when this table was just absent in a class,
an error was returned 
just like parsing was failed.


tested on ubuntu - smoke and c-unit passed



Modified:
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/Class.h
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class_File_Loader.cpp

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/Class.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/Class.h?view=diff&rev=447080&r1=447079&r2=447080
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/Class.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/Class.h Sun Sep 17 08:26:53 2006
@@ -1608,9 +1608,6 @@
 
     bool _parse_line_numbers(unsigned attr_len, ByteReader &cfs);
 
-    bool _parse_local_vars(Const_Pool *cp, unsigned cp_size,
-        unsigned attr_len, ByteReader &cfs);
-
     bool _parse_exceptions(Const_Pool *cp, unsigned cp_size, unsigned attr_len,
         ByteReader &cfs);
 
@@ -1622,8 +1619,8 @@
     Line_Number_Table *_line_number_table;
     Local_Var_Table *_local_vars_table;
 
-    Local_Var_Table * _parse_local_vars(Const_Pool *cp, unsigned cp_size, 
-        unsigned attr_len, ByteReader &cfs, const char* attr_name);
+    bool _parse_local_vars(const char* attr_name, Local_Var_Table** lvt_address,
+        Const_Pool *cp, unsigned cp_size, unsigned attr_len, ByteReader &cfs);
 
     // This is the number of breakpoints which should be set in the
     // method when it is compiled. This number does not reflect

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class_File_Loader.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class_File_Loader.cpp?view=diff&rev=447080&r1=447079&r2=447080
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class_File_Loader.cpp
(original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class_File_Loader.cpp
Sun Sep 17 08:26:53 2006
@@ -1126,27 +1126,29 @@
     return true;
 } //Method::_parse_line_numbers
 
-Local_Var_Table * Method::_parse_local_vars(Const_Pool *cp, unsigned cp_size, 
-                               unsigned attr_len, ByteReader &cfs, const char* attr_name)
{
 
+bool Method::_parse_local_vars(const char* attr_name, Local_Var_Table** lvt_address,
+        Const_Pool *cp, unsigned cp_size, unsigned attr_len, ByteReader &cfs)
+{
     uint16 n_local_vars;
     if(!cfs.parse_u2_be(&n_local_vars)) {
         REPORT_FAILED_METHOD("could not parse local variables number "
             "of " << attr_name << " attribute");
-        return NULL;
+        return false;
     }
+
     unsigned real_lnt_attr_len = 2 + n_local_vars * 10; 
     if(real_lnt_attr_len != attr_len) {
         REPORT_FAILED_METHOD("real " << attr_name << " length differ "
             "from declared length ("
             << attr_len << " vs. " << real_lnt_attr_len << ")" );
-        return NULL;
+        return false;
     }
     if (!n_local_vars) {
-        return NULL;
+        return true;
     }
 
-    Local_Var_Table * table = (Local_Var_Table *)_class->class_loader->Alloc(
+    Local_Var_Table* table = (Local_Var_Table *)_class->class_loader->Alloc(
         sizeof(Local_Var_Table) +
         sizeof(Local_Var_Entry) * (n_local_vars - 1));
     // ppervov: FIXME: should throw OOME
@@ -1157,62 +1159,62 @@
         if(!cfs.parse_u2_be(&start_pc)) {
             REPORT_FAILED_METHOD("could not parse start_pc "
                 "in " << attr_name << " attribute");
-            return NULL;
+            return false;
         }
         uint16 length;      
         if(!cfs.parse_u2_be(&length)) {
             REPORT_FAILED_METHOD("could not parse length entry "
                 "in " << attr_name << " attribute");
-            return NULL;
+            return false;
         }
 
         if( (start_pc >= _byte_code_length)
             || (start_pc + (unsigned)length) > _byte_code_length ) {
             REPORT_FAILED_METHOD(attr_name << " entry "
                 "[start_pc, start_pc + length) points outside bytecode range");
-            return NULL;
+            return false;
         }
 
         uint16 name_index;
         if(!cfs.parse_u2_be(&name_index)) {
             REPORT_FAILED_METHOD("could not parse name index "
                 "in " << attr_name << " attribute");
-            return NULL;
+            return false;
         }
 
         uint16 descriptor_index;
         if(!cfs.parse_u2_be(&descriptor_index)) {
             REPORT_FAILED_METHOD("could not parse descriptor index "
                 "in " << attr_name << " attribute");
-            return NULL;
+            return false;
         }
 
         String* name = cp_check_utf8(cp,cp_size,name_index);
         if(name == NULL) {
             REPORT_FAILED_METHOD("name index is not valid CONSTANT_Utf8 entry "
                 "in " << attr_name << " attribute");
-            return NULL;
+            return false;
         }
 
         String* descriptor = cp_check_utf8(cp,cp_size,descriptor_index);
         if(descriptor == NULL) {
             REPORT_FAILED_METHOD("descriptor index is not valid CONSTANT_Utf8 entry "
                 "in " << attr_name << " attribute");
-            return NULL;
+            return false;
         }
 
         uint16 index;
         if(!cfs.parse_u2_be(&index)) {
             REPORT_FAILED_METHOD("could not parse index "
                 "in " << attr_name << " attribute");
-            return NULL;
+            return false;
         }
 
         // FIXME Don't work with long and double
         if (index >= _max_locals) {
             REPORT_FAILED_METHOD("invalid local index "
                 "in " << attr_name << " attribute");
-            return NULL;
+            return false;
         }
 
         table->table[j].start_pc = start_pc;
@@ -1223,9 +1225,13 @@
         table->table[j].generic_type = NULL;
     }
 
-    return table;
+    assert(lvt_address);
+    *lvt_address = table;
+
+    return true;
 } //Method::_parse_local_vars
 
+
 bool Method::_parse_code( Const_Pool *cp, unsigned cp_size, unsigned code_attr_len, ByteReader
&cfs)
 {
     unsigned real_code_attr_len = 0;
@@ -1344,8 +1350,7 @@
             {
                 if (TI_enabled)
                 {
-                    if (!(_local_vars_table = 
-                        _parse_local_vars(cp, cp_size, attr_len, cfs, "LocalVariableTable")))
+                    if (!_parse_local_vars("LocalVariableTable", &_local_vars_table,
cp, cp_size, attr_len, cfs))
                     {
                         return false;
                     }
@@ -1360,8 +1365,7 @@
             {
                 if (TI_enabled)
                 {
-                    if (!(generic_vars = 
-                        _parse_local_vars(cp, cp_size, attr_len, cfs, "LocalVariableTypeTable")))
+                    if (!_parse_local_vars("LocalVariableTypeTable", &generic_vars, cp,
cp_size, attr_len, cfs))
                     {
                         return false;
                     }



Mime
View raw message