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


> Does this thing use DWARF based exception handling?

I'm not sure what that means, but it looks like FreeBSD since 3.x have
used DWARF.  I'm on x86, so it's pretty standard hardware.

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

Changing the code to:

public class NullPointer
{
  private int i = 5;
  private static int j = 10;

  public static void main(String[] args)
  {
    try
    {
      new NullPointer().foo(null);
    }
    catch (NullPointerException x)
    {
      System.out.println(x);
    }
  }

  void foo(NullPointer e)
  {
    NullPointer.j += 5;
    e.i += 4;
  };
}

and (from Bryce's suggestion) changing the compile line to:

/opt/gcc-4.1/bin/gcj -fnon-call-exceptions -o nullpointer
NullPointer.java --main=NullPointer

Assuming that's what was desired, running the program still results in
"Abort trap (core dumped)".  The output when adding -v to the gcj call
is:

/opt/gcc-4.1/bin/gcj -fnon-call-exceptions -v -o nullpointer
NullPointer.java --main=NullPointer
Using built-in specs.
Reading specs from
/usr/opt/gcc-4.1/bin/../lib/gcc/i386-unknown-freebsd5.4/4.1.0/../../../libgcj.spec
rename spec lib to liborig
Target: i386-unknown-freebsd5.4
Configured with: ../gcc-4.1-20051029/configure --prefix=/opt/gcc-4.1
--enable-languages=c c++ java
Thread model: posix
gcc version 4.1.0 20051026 (experimental)
 /usr/opt/gcc-4.1/bin/../libexec/gcc/i386-unknown-freebsd5.4/4.1.0/jc1
NullPointer.java -fhash-synchronization -fuse-divide-subroutine
-fcheck-references -fuse-boehm-gc -fkeep-inline-functions -quiet
-dumpbase NullPointer.java -auxbase NullPointer -g1 -version
-fnon-call-exceptions -o /var/tmp//ccw95Ilx.s
GNU Java version 4.1.0 20051026 (experimental) (i386-unknown-freebsd5.4)
        compiled by GNU C version 3.4.2 [FreeBSD] 20040728.
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Class path starts here:
    ./
    /usr/opt/gcc-4.1/bin/../lib/gcc/../../share/java/libgcj-4.1.0.jar/
(system) (zip)
 as -o /var/tmp//ccDAVstC.o /var/tmp//ccw95Ilx.s
 /usr/opt/gcc-4.1/bin/../libexec/gcc/i386-unknown-freebsd5.4/4.1.0/jvgenmain
NullPointermain /var/tmp//cckljDY3.i
 /usr/opt/gcc-4.1/bin/../libexec/gcc/i386-unknown-freebsd5.4/4.1.0/cc1
/var/tmp//cckljDY3.i -quiet -dumpbase NullPointermain.c -g1 -version
-fnon-call-exceptions -fdollars-in-identifiers -o /var/tmp//ccw95Ilx.s
GNU C version 4.1.0 20051026 (experimental) (i386-unknown-freebsd5.4)
        compiled by GNU C version 3.4.2 [FreeBSD] 20040728.
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 5afbc6e8e486d673f7ee8d85be651a85
 as -o /var/tmp//ccfEx9ZC.o /var/tmp//ccw95Ilx.s
 /usr/opt/gcc-4.1/bin/../libexec/gcc/i386-unknown-freebsd5.4/4.1.0/collect2
-V -dynamic-linker /usr/libexec/ld-elf.so.1 -o nullpointer
/usr/lib/crt1.o /usr/lib/crti.o
/usr/opt/gcc-4.1/bin/../lib/gcc/i386-unknown-freebsd5.4/4.1.0/crtbegin.o
-L/usr/opt/gcc-4.1/bin/../lib/gcc/i386-unknown-freebsd5.4/4.1.0
-L/usr/opt/gcc-4.1/bin/../lib/gcc
-L/opt/gcc-4.1/lib/gcc/i386-unknown-freebsd5.4/4.1.0
-L/usr/opt/gcc-4.1/bin/../lib/gcc/i386-unknown-freebsd5.4/4.1.0/../../..
-L/opt/gcc-4.1/lib/gcc/i386-unknown-freebsd5.4/4.1.0/../../..
/var/tmp//ccfEx9ZC.o /var/tmp//ccDAVstC.o -lgcc_s -lgcc -lgcj -lm
-lc_r -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/opt/gcc-4.1/bin/../lib/gcc/i386-unknown-freebsd5.4/4.1.0/crtend.o
/usr/lib/crtn.o
GNU ld version 2.15 [FreeBSD] 2004-05-23
  Supported emulations:
   elf_i386_fbsd


Hope that helps!


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