Re: [Code] [Newbie] help with GDB

From: Erwin S. Andreasen (erwin@PIP.DKNET.DK)
Date: 07/16/97


On Tue, 15 Jul 1997, George wrote:


> >Program terminated with signal 11, Segmentation fault.
> >#0  0xef6ab3d8 in fprintf ()
>
> I hate when it does that...but it's better than nothing.  Basically your
> program crashed trying to do an fprintf().  Look for one in your save

BTW, If you're really desperate, getting an overrun in some sprintf
*somewhere* that you just can't track down, and it doesn't seem to be
related to acommand, you could try defininig sprintf (or whatever printf)
as a macro that save the location of the current sprintf then does the
sprintf - and, install some ocde which writes this buffer as a SIGSEGV is
received (see for example my homepage, the last command gadge in the
'short stuff' package):

#define sprintf(buf, fmt, args...) (\
{\
        strcpy (crash_buffer, __FUNCTION__); \
        strcat (crash_buffer, fmt);\
        sprintf(buf, fmt, ##args);\
})

This requires gcc.

BTW, examining the stack might sometimes tell you what string was printed
and help you track it down, but in my case, it didn't.

Note that the above is very CPU intensive (cpu usage jumped from 3-4% to
12 AFAIR).

 =============================================================================
Erwin Andreasen   Herlev, Denmark <erwin@pip.dknet.dk>  UNIX System Programmer
<URL:http://pip.dknet.dk/~erwin/>                       (not speaking for) DDE
 =============================================================================


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST