httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Terbush <ra...@zyzzyva.com>
Subject Re: WWW Form Bug Report: "signal handlers use non-rentrant functions" on OTHER:NetBSD
Date Wed, 04 Dec 1996 16:55:30 GMT

Perhaps we need to suspend the signal mask when entering these functions?


> Randy Terbush <randy@zyzzyva.com> writes:
> 
> > I took a stab at this. The question is how many other places need this
> > sort of change? sprintf is considered safe on Solaris.
> > 
> 
> After actually looking at the patch, this is missing the real
> point. You're still making a function call after a trap and that's not
> safe to start with, the stack may not be in any sound state, the
> data structures may be hosed. *Something* caused the trap in the first
> place, how do you know it isn't what you're subsequently going to try
> and use?
> 
> Take a look at the new Perl5 signal documentation, it makes the point
> that about all you should do in such a case is die and even that isn't
> guaranteed to be safe.
> 
> > Index: http_log.c
> > ===================================================================
> > RCS file: /export/home/cvs/apache/src/http_log.c,v
> > retrieving revision 1.10
> > diff -c -r1.10 http_log.c
> > *** http_log.c	1996/12/01 20:28:25	1.10
> > --- http_log.c	1996/12/04 02:10:20
> > ***************
> > *** 145,157 ****
> >       fclose(pid_file);
> >   }
> >   
> > ! void log_error(char *err, server_rec *s) {
> > !     fprintf(s->error_log, "[%s] %s\n",get_time(),err);
> > !     fflush(s->error_log);
> >   }
> >   
> > ! void
> > ! log_unixerr(const char *routine, const char *file, const char *msg,
> >   	    server_rec *s)
> >   {
> >       const char *p, *q;
> > --- 145,160 ----
> >       fclose(pid_file);
> >   }
> >   
> > ! void log_error(char *err, server_rec *s)
> > ! {
> > !     int len;
> > !     char buf[512];
> > !     
> > !     len = sprintf(buf, "[%s] %s\n", get_time(), err);
> > !     write(fileno(s->error_log), buf, len + 1);
> >   }
> >   
> > ! void log_unixerr(const char *routine, const char *file, const char *msg,
> >   	    server_rec *s)
> >   {
> >       const char *p, *q;
> > 
> > 
> > 
> > 
> > > Rob Hartill wrote:
> > > > 
> > > > 
> > > > Thanks for the patch. I'll forward it to the developers list.
> > > > 
> > > > cheers,
> > > > rob
> > > > 
> > > > Liz Stokes wrote:
> > > > >> ilaine@panix.com wrote:
> > > > >> >
> > > > >> >Submitter: ilaine@panix.com
> > > > >> >Operating system: OTHER:NetBSD, version: 1.2_BETA
> > > > >> >Version of Apache Used: 1.1.1
> > > > >> >Extra Modules used: 
> > > > >> >URL exhibiting problem: 
> > > > >> >
> > > > >> >Symptoms:
> > > > >> >--
> > > > >> >sig_term, sig_bus, and sig_fault all call log_error, which
calls many
> > > > >> >non re-entrant functions. In the example which brought the
problem to my
> > > > >> >attention, httpd was in vfprintf when it received a SIGSEGV.
It
> > > > >> >called log_error which caused it to re-enter vfprintf with
unhappy
> > > > >> >results - it went into a tight loop inside vfprintf and chewed
cycles
> > > > >> >at a prodigious rate till exterminated.
> > > > >> >
> > > > >> >I have patched our version to use a simple write() inside
the signal handlers
> > > > >> >instead of log_error. It's not terribly elegant, and of course
you lose the
> > > > >> >timestamp, but I'd be happy to provide the diff if you wish.
> > > > >> 
> > > > >> Thanks for the info. Apache 1.2b1 will be released in the next
few hours.
> > > > >> Many bugs have been fixed and problems resolved. Can you send
us a patch
> > > > >> for 1.2b1 if the problem persists.
> > > > >
> > > > >The bug is still there - the signal handlers are unchanged. Appended
is a 
> > > > >diff for http_main.c
> > > > >
> > > > >-Liz
> > > > >
> > > > >
> > > > >*** http_main.c	Sun Dec  1 15:28:26 1996
> > > > >--- http_main.c.new	Tue Dec  3 14:58:52 1996
> > > > >***************
> > > > >*** 1066,1072 ****
> > > > >  }
> > > > >  
> > > > >  void sig_term() {
> > > > >!     log_error("httpd: caught SIGTERM, shutting down", server_conf);
> > > > >      cleanup_scoreboard();
> > > > >  #ifndef NO_KILLPG
> > > > >      killpg(pgrp,SIGKILL);
> > > > >--- 1066,1073 ----
> > > > >  }
> > > > >  
> > > > >  void sig_term() {
> > > > >!     write (fileno(server_conf->error_log),
> > > > >!            "httpd: caught SIGTERM, shutting down\n", 38);
> > > > >      cleanup_scoreboard();
> > > > >  #ifndef NO_KILLPG
> > > > >      killpg(pgrp,SIGKILL);
> > > > >***************
> > > > >*** 1079,1085 ****
> > > > >  }
> > > > >  
> > > > >  void bus_error() {
> > > > >!     log_error("httpd: caught SIGBUS, dumping core", server_conf);
> > > > >      chdir(server_root);
> > > > >      abort();         
> > > > >      exit(1);
> > > > >--- 1080,1087 ----
> > > > >  }
> > > > >  
> > > > >  void bus_error() {
> > > > >!     write (fileno(server_conf->error_log),
> > > > >!            "httpd: caught SIGBUS, dumping core\n", 36);
> > > > >      chdir(server_root);
> > > > >      abort();         
> > > > >      exit(1);
> > > > >***************
> > > > >*** 1086,1092 ****
> > > > >  }
> > > > >  
> > > > >  void seg_fault() {
> > > > >!     log_error("httpd: caught SIGSEGV, dumping core", server_conf);
> > > > >      chdir(server_root);
> > > > >      abort();
> > > > >      exit(1);
> > > > >--- 1088,1095 ----
> > > > >  }
> > > > >  
> > > > >  void seg_fault() {
> > > > >!     write (fileno(server_conf->error_log),
> > > > >!            "httpd: caught SIGSEGV, dumping core\n", 37);
> > > > >      chdir(server_root);
> > > > >      abort();
> > > > >      exit(1);
> > > > >
> > > > >
> > > > 
> > > > 
> > > 
> > > -- 
> > > Ben Laurie                Phone: +44 (181) 994 6435  Email: ben@algroup.co.uk
> > > Freelance Consultant and  Fax:   +44 (181) 994 6472
> > > Technical Director        URL: http://www.algroup.co.uk/Apache-SSL
> > > A.L. Digital Ltd,         Apache Group member (http://www.apache.org)
> > > London, England.          Apache-SSL author
> > 
> > 
> > 
> 
> -- 
>   Paul Richards. Originative Solutions Ltd.  (Netcraft Ltd. contractor)
>   Elsevier Science TIS online journal project.
>   Email: p.richards@elsevier.co.uk
>   Phone: 0370 462071 (Mobile), +44 (0)1865 843155




Mime
View raw message