This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

The old _Jv_InitClass problem is still present in 3.1 (patch included)



Hi!

This was fixed some time ago for 3.0.*, but it is present in 3.1, too.
(cf. http://gcc.gnu.org/ml/java-patches/2001-q3/msg00062.html 
some later parts of the thread seem to be below 
http://gcc.gnu.org/ml/java/2001-07/msg00173.html, too)

The problem is:
The compiler may generate calls to _Jv_IsAssignableFrom by its own (i.e. not
all of its calls come from libjava).
Then the classes may be uninitialized and my application segfaults.
The fix is the same like it was in 3.0.*.
It may be a performance problem, though.

The other possibility is to ensure, that classes where _Jv_IsAssignableFrom
or _Jv_IsInstanceOf is called on, are initialized.

Here is the relevant stack frame before the bug (i do not know, where the strange line
information comes from, this is gdb-5.0):

0x401b7e31 in _Z20_Jv_IsAssignableFromPN4java4lang5ClassES2_ (target=0x8720b20, source=0x875c0a0) 
    at ../../../gcc-3.1/libjava/java/lang/natClass.cc:959
#1  0x401b7f10 in _Jv_IsInstanceOf (obj=0x89cce70, cl=0x8720b20) 
    at ../../../gcc-3.1/libjava/java/lang/natClass.cc:994
#2  0x81b7377 in _ZN4VHDL2VC8Database12VCDN_Library17getDesignUnitNameEPNS1_17VCDN_Design_U_nitE (this=0x89ccee0, uNode=0x89cce70) 
    at VHDL/VC/Database/VCDN_Library.java:0  (this is inside my code)
#3  0x81b0328 in _ZN4VHDL2VC8Database16VCDN_Design_File8addChildEPNS1_9VCDN_NodeE (this=0x89ae460, unitNode=0x89cce70) 
    at VHDL/VC/Database/VCDN_Design_File.java:0 (this is inside my code)
....

Bye,
Martin.


2001-09-27  Martin Kahlert  <martin.kahlert@infineon.com>

	* java/lang/natClass.cc: Move calls of _Jv_InitCLass from
	isAssignableFrom and isInstance to _Jv_IsAssignableFrom

*** natClass.cc.old	Thu Sep 27 15:03:36 2001
--- natClass.cc	Thu Sep 27 15:03:08 2001
***************
*** 624,632 ****
  jboolean
  java::lang::Class::isAssignableFrom (jclass klass)
  {
-   // Arguments may not have been initialized, given ".class" syntax.
-   _Jv_InitClass (this);
-   _Jv_InitClass (klass);
    return _Jv_IsAssignableFrom (this, klass);
  }
  
--- 624,629 ----
***************
*** 635,641 ****
  {
    if (! obj)
      return false;
-   _Jv_InitClass (this);
    return _Jv_IsAssignableFrom (this, JV_CLASS (obj));
  }
  
--- 632,637 ----
***************
*** 910,915 ****
--- 906,915 ----
  jboolean
  _Jv_IsAssignableFrom (jclass target, jclass source)
  {
+   // Arguments may not have been initialized, given ".class" syntax.
+   _Jv_InitClass (target);
+   _Jv_InitClass (source);
+ 
    if (source == target)
      return true;
       

-- 
The early bird catches the worm. If you want something else for       
breakfast, get up later.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]