public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Daney <ddaney@caviumnetworks.com>
To: Ben Gardiner <BenGardiner@nanometrics.ca>
Cc: Andrew Haley <aph@redhat.com>, GCJ <java@gcc.gnu.org>
Subject: Re: libSegFault.so and gcj
Date: Fri, 15 May 2009 20:49:00 -0000	[thread overview]
Message-ID: <4A0DD4C4.3050006@caviumnetworks.com> (raw)
In-Reply-To: <4A0DCF4D.1030506@nanometrics.ca>

Ben Gardiner wrote:
> Andrew Haley wrote:
>>> I reason from this that the segfaults are likely stack overflows. Could
>>> anyone confirm this?
>>>     
>> That's quite possible.  Do you not have a debugger?
>>
>> Clearly if it really is a stack overflow then you're not going to be
>> able to call the null pointer handler.  There is a way around this,
>> though.  If you use the -fstack-check option gcc generates a probe
>> at the start of every method that writes a zero some 12kbytes below
>> the stack pointer.  This will give you enough stack space for the
>> catch_segv handler to run.
> David Daney wrote:
>> Usually if you die with a SIGSEGV, it is due to stack overflow.
>> Probably for one reason or another you are getting a fault during the
>> NullPointerException processing which causes the signal handler to be
>> reentered recursively.  This goes on until the stack overflows and the
>> kernel then kills the process.  If you could attach a debugger to the
>> process, that might shed some light on exactly what is happening.
>> Assuming that it is not normal for your application to take
>> NullPointerExceptions it shouldn't be too tedious.
> Andrew and David, thank you for your insights and for the speed with 
> which they were provided.
> 
> About the debugger; I agree it would be the easiest way to figure out 
> what's going on here. Since I don't know how to reproduce the problem I 
> was hoping to get some information from our devices in the field if and 
> when they die of a segmentation fault.
> 
> Would it be possible -- and if so, are there any significant drawbacks 
> -- to store the previous handler in INIT_SEGV and register it when 
> catch_segv is entered, then re-register catch_segv on the way out? Would 
> this allow the segv signal to be passed up to libSegFault.so's handler 
> when it would have otherwise resulted in a recursive dead-end?
> 

I think it would be very difficult to get that to work.  You would have 
to restore the handler in catch_segv, but where would you reregister 
catch_segv?  Actually I am not sure, but it is in either the java 
personality routine or the unwinder in libgcc.  The problem is:  what do 
you do for a multi-threaded application?  Thread A has to be able to 
handle SIGSEGV while thread B is unwinding its own exceptions.  Making 
sure that there were no race conditions could be difficult.

David Daney

  reply	other threads:[~2009-05-15 20:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-14 15:28 Ben Gardiner
2009-05-14 16:04 ` Andrew Haley
2009-05-15  9:17   ` Andrew Haley
2009-05-15 20:23   ` Ben Gardiner
2009-05-15 20:49     ` David Daney [this message]
2009-05-14 16:10 ` David Daney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A0DD4C4.3050006@caviumnetworks.com \
    --to=ddaney@caviumnetworks.com \
    --cc=BenGardiner@nanometrics.ca \
    --cc=aph@redhat.com \
    --cc=java@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).