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 wrote:
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.

Does this thing use DWARF based exception handling?


If so my guess would be a problem with MAKE_THROW_FRAME on this platfrom.

If making the first statement of foo something other than dereferencing the null pointer (like increment a static int) fixes the problem then I would be even more confident about this.

David Daney.


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