[CS-FSLUG] OT: C program crashes

Frank Bax fbax at sympatico.ca
Thu Feb 9 13:34:06 CST 2006


I've got some C source code that sometimes crashes with a SIG11, which I 
believe to be a seg fault.  The program I'm playing with was a free one I 
got on the web and runs as cgi script.  It randomly fails with Sig 11 
errors.  Very early in main.c, I see call to setsigs():

void setsigs()
{
         short int i;
#ifdef _NSIG
         short int numsigs=_NSIG;
#else
         short int numsigs=NSIG;
#endif

         if (numsigs>16) numsigs=16;
         for(i=0;i<numsigs;i++) {
                 signal(i, sig_catchint);
         }
#ifdef WIN32
         SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOGPFAULTERRORBOX|SEM_NOOPENFILEERRORBOX);
#else
         signal(SIGALRM, sig_timeout);
         alarm(config.max_runtime);
#endif
}


It seems that when the Sig11 is "caught", this function is invoked:
void sig_catchint(int sig)
{
         send_header(0, "1", "text/html", -1, -1);
         printf("<B>Caught unhandled signal %d.</B>\n", sig);
#ifndef WIN32
         if (config.use_syslog=='y') {
                 closelog();
         }
#endif
         exit(0);
}


What could I add/modify to get some clue as to where the real fault is in 
the software?





More information about the Christiansource mailing list