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 02:15:26 GMT
> All right! This is probably the cause of all the mysterious spins we've been
> seeing. I think I'd prefer a proper fix, though. Could log_error be made safe
> instead?
> 
> Cheers,
> 
> Ben.

I took a stab at this. The question is how many other places need this
sort of change? sprintf is considered safe on Solaris.

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




Mime
View raw message