Re: How can I trace a segfault on program start?
On Tue, Jul 17, 2001 at 05:02:52PM +0100, Oliver Elphick wrote:
> "Eric G. Miller" wrote:
> >On Tue, Jul 17, 2001 at 11:04:52AM +0100, Oliver Elphick wrote:
> >> I have compiled a program with gcc 2.95. It segfaults immediately on star
> >ting
> >> and neither gdb nor strace reveal any useful information:
> >>
> >>
> >> olly@linda:.../src$ people
> >> Segmentation fault (core dumped)
> >> olly@linda:.../src$ gdb people
> >> GNU gdb 2001-07-05-cvs (MI_OUT)
> >> ...
> >> (gdb) run
> >> Starting program: /usr1/proj/bray/gtk/people_glade/src/people
> >>
> >> Program received signal SIGSEGV, Segmentation fault.
> >> 0x00000001 in ?? ()
> >> (gdb) bt
> >> #0 0x00000001 in ?? ()
> >> Cannot access memory at address 0x0
> > ^^^^
> > Obviously an error.
>
>
> Obviously! But what is causing it? This happens while the program is
> loading, before any of my own code is executed.
Looks like an attempt to dereference a NULL pointer, but I can't tell
for sure. Sure your not passing a NULL pointer to a function early on
that actually expects allocated memory already? I'd say post the code,
if you can, but this probably isn't the best forum...
The suggestion of putting in a breakpoint at the beginning and stepping
through might help. If the problem is actually in a library, you
probably can't get any good information unless you make sure it's
compiled with -g and is not stripped. Using -Wall can sometimes warn
about certain errors (like uninitialized pointers)...
--
Eric G. Miller <egm2@jps.net>
Reply to: