This is the mail archive of the java@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]
Other format: [Raw text]

Re: [re] Java executables can abort trying to access a null pointer in a leaf function


tsuraan writes:
 > In April, 2000, the following code was posted to the java-gnats at
 > cygnus mailing list as a piece of code that causes a gcj compiled
 > program to abort rather than printing out the NullPointerException and
 > exiting:
 > 
 > public class NullPointer
 > {
 >   private int i = 5;
 > 
 >   public static void main(String[] args)
 >   {
 >     try
 >     {
 >       new NullPointer().foo(null);
 >     }
 >     catch (NullPointerException x)
 >     {
 >       System.out.println(x);
 >     }
 >   }
 > 
 >   void foo(NullPointer e)
 >   {
 >     e.i += 4;
 >   };
 > }
 > 
 > I'm getting the same result (program exit with abort) using
 > gcc-4.1-20051029 under FreeBSD 5.4.  This happens reliably on many
 > machines.  This code works fine using the same gcc source under Gentoo
 > Linux with a 2.6.x kernel, so I assume FreeBSD is handling things a
 > bit differently and causing the abort.  I tried to test this under the
 > current svn trunk, but when I attempt to run 'gmake install' I run out
 > of memory, so that's not going to work.  If someone who can install a
 > fresh version of gcc under freebsd 5.4 could verify this or say that
 > it's no longer an issue, I'd be very appreciative.

This happens if unwinder data in a leaf function is incorrect or
incomplete.  Such bugs have been fixed a few times in recent years.
The most recent one was

http://gcc.gnu.org/ml/gcc-patches/2005-12/msg00094.html

So, before blaming the kernel, check that the unwinder data for foo is
correct.

Andrew.


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