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]

Patch to avoid SegFault in natClass.cc



Hi!

This patch allows me to run my application with Electric Fence again.
Without this patch, it segfaults in natClass.cc (_Jv_IsAssignableFrom).

The reason is this: The application
has a line 
if( sSymb instanceof VCDS_Reference)
where VCDS_Reference is an abstract class. 
The application seems to use the .classs syntax quite often.
(see http://gcc.gnu.org/ml/java/2001-07/msg00101.html and all the
messages with subject 'What classes have depth==0?').

The compiler generates a direct call to _Jv_IsInstanceOf, it does *not*
call java::lang::Class::isInstance, which would have called _Jv_InitClass
first.

In order to avoid code bloat, i moved the calls into the 'lower level routines'.

I hope, this patch is correct, but i assume, it doesn't harm and it works with
my very large app.

It would be nice if it would make it into the 3.0.1 release.

Thanks a lot,
Martin.



2001-07-13  Martin Kahlert  <martin.kahlert@infineon.com>

	*  java/lang/natClass.cc: Move calls of _Jv_InitClass from
	java::lang::Class::isAssignableFrom and java::lang::Class::isInstance
	into _Jv_IsAssignableFrom

diff -rc gcc-20010709.orig/libjava/java/lang/natClass.cc gcc-20010709/libjava/java/lang/natClass.cc
*** gcc-20010709.orig/libjava/java/lang/natClass.cc	Tue Jun  5 11:56:10 2001
--- gcc-20010709/libjava/java/lang/natClass.cc	Fri Jul 13 10:46:48 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 ----
***************
*** 909,914 ****
--- 905,914 ----
  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]