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

David Daney ddaney@avtrex.com
Wed Feb 1 22:53:00 GMT 2006


tsuraan wrote:
>>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)". 

Look at the bright side here. At least you have a core file. Now you 
can load this thing into gdb and get a stacktrace.
David Daney


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /