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


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

Java: backtrace alignment fault


This is a critical patch for all 64-bit Java systems.

The backtrace code contained an illegal pointer cast which, with the
new ABI, caused failures on 64-bit machines.

I have checked this in to 3.0 and the trunk.

Andrew.

2001-03-01  Andrew Haley  <aph@redhat.com>

	* java/lang/natThrowable.cc (printRawStackTrace): Copy the
	stackTrace buffer to a correctly aligned pointer array.
 
Index: java/lang/natThrowable.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natThrowable.cc,v
retrieving revision 1.8
diff -p -2 -c -r1.8 natThrowable.cc
*** java/lang/natThrowable.cc	2000/12/22 06:19:24	1.8
--- java/lang/natThrowable.cc	2001/03/14 15:40:27
*************** java::lang::Throwable::fillInStackTrace 
*** 66,70 ****
    if (n > 0)
      {
!       // ???  Might this cause a problem if the byte array isn't aligned?
        stackTrace = JvNewByteArray (n * sizeof p[0]);
        memcpy (elements (stackTrace), p+1, (n * sizeof p[0]));
--- 66,70 ----
    if (n > 0)
      {
!       // We copy the array below to deal with alignment issues.
        stackTrace = JvNewByteArray (n * sizeof p[0]);
        memcpy (elements (stackTrace), p+1, (n * sizeof p[0]));
*************** java::lang::Throwable::printRawStackTrac
*** 84,89 ****
      return;
  
!   void **p = (void **)elements (stackTrace);
!   int depth = stackTrace->length / sizeof p[0];
  
    _Jv_name_finder finder (_Jv_ThisExecutable ());
--- 84,90 ----
      return;
  
!   int depth = stackTrace->length / sizeof (void *);
!   void *p[depth];
!   memcpy (p, elements (stackTrace), sizeof p);
  
    _Jv_name_finder finder (_Jv_ThisExecutable ());


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