On 2009/04/14 11:08, Nick Holland wrote:
> It is really easy to reproduce...in X, ssh to machine with Epic, start  
> Epic4 in an xterm, now resize the x-term.  Boom.  Epic4 is now locked,  
> and soaking all available CPU time.

I can repeat this with -O2 but not -O0. I bet this is the "random hangs"
you mentioned James.

> bah.  Well, the same friend that found the problem and I *thought* said 
> "the solution is to run epic5" just gave me this link, which has a  
> considerably simpler solution...
> http://www.mail-archive.com/l...@epicsol.org/msg00593.html

so here's a possible candidate...

Index: Makefile
===================================================================
RCS file: /cvs/ports/net/epic4/Makefile,v
retrieving revision 1.66
diff -N -u -p Makefile
--- Makefile    14 Apr 2009 09:37:49 -0000      1.66
+++ Makefile    14 Apr 2009 20:22:51 -0000
@@ -5,7 +5,7 @@ COMMENT=        (E)nhanced (P)rogrammable (I)RC-II (C)lient
 VERSION=       2.10
 HELP_DATE=     20050315
 DISTNAME=      epic4-${VERSION}
-PKGNAME=       ${DISTNAME}p1
+PKGNAME=       ${DISTNAME}p2
 CATEGORIES=    net
 MASTER_SITES=  ftp://ftp.epicsol.org/pub/epic/EPIC4-PRODUCTION/
 DISTFILES=     epic4-${VERSION}.tar.bz2 epic4-help-${HELP_DATE}.tar.gz
@@ -28,8 +28,6 @@ SEPARATE_BUILD=       simple
 CONFIGURE_STYLE=       gnu
 # conflict between Perl embed headers and uvm_map's {max,min}_offset defines.
 CONFIGURE_ENV=         ac_cv_header_sys_sysctl_h=no
-# using a lower optimisation level prevents random hangs (gcc 3.3.5, 2009/04)
-CFLAGS+= -O0
 
 CONFIGURE_ARGS=        --without-tcl \
                --enable-perl
Index: patches/patch-source_irc_c
===================================================================
RCS file: patches/patch-source_irc_c
diff -N -u -p patches/patch-source_irc_c
--- /dev/null   14 Apr 2009 20:22:51 -0000
+++ patches/patch-source_irc_c  14 Apr 2009 20:22:51 -0000
@@ -0,0 +1,21 @@
+$OpenBSD$
+--- source/irc.c.orig  Sat Mar 29 04:49:23 2008
++++ source/irc.c       Tue Apr 14 21:12:58 2009
+@@ -52,7 +52,7 @@ const char internal_version[] = "20080329";
+ /*
+  * In theory, this number is incremented for every commit.
+  */
+-const unsigned long   commit_id = 769;
++const unsigned long   commit_id = 770;
+ 
+ /*
+  * As a way to poke fun at the current rage of naming releases after
+@@ -1155,7 +1155,7 @@ int      main (int argc, char *argv[])
+       /* make sure we don't start with spurious signals events firing */
+       memset(&signals_caught, 0, NSIG * sizeof(int));
+       /* hook all signals! */
+-      hook_all_signals();
++      init_signals();
+       /* we *might* want to check for SIG_ERR from the above function.
+        * i leave it to hop to decide what to do on SIG_ERR. -pegasus 
+        */
Index: patches/patch-source_ircsig_c
===================================================================
RCS file: patches/patch-source_ircsig_c
diff -N -u -p patches/patch-source_ircsig_c
--- /dev/null   14 Apr 2009 20:22:51 -0000
+++ patches/patch-source_ircsig_c       14 Apr 2009 20:22:51 -0000
@@ -0,0 +1,138 @@
+$OpenBSD$
+--- source/ircsig.c.orig       Fri Mar 14 00:12:53 2008
++++ source/ircsig.c    Tue Apr 14 21:12:59 2009
+@@ -57,12 +57,13 @@ int        unblock_signal (int sig_no)
+ }
+ 
+ /* array of signal handlers containing mostly NULL */
+-volatile sigfunc *signal_handlers[NSIG];
++sigfunc *signal_handlers[NSIG];
++volatile int    signals_caught[NSIG];
+ 
+-/* grand unified signal handler, which sets flags for scriptable signals 
+- * -pegasus 
++/* grand unified signal handler, which sets flags for scriptable signals
++ * - pegasus
+  */
+-RETSIGTYPE signal_handler (int sig_no)
++static RETSIGTYPE signal_handler (int sig_no)
+ {
+       signals_caught[0] = 1;
+       signals_caught[sig_no]++;
+@@ -70,63 +71,74 @@ RETSIGTYPE signal_handler (int sig_no)
+               signal_handlers[sig_no](sig_no);
+ }
+ 
+-/* hook_all_signals needs to be called in main() before my_signal()
+- * if any signal hooks fail, it returns SIG_ERR, otherwise it returns 
+- * NULL. -pegasus
+- */
+-sigfunc *hook_all_signals (void)
++sigfunc *reset_one_signal (int sig_no, sigfunc *sig_handler)
+ {
+-        struct sigaction sa, osa;
+-      int sig_no;
+-      sigfunc *error = NULL;
++      struct sigaction sa, osa;
+ 
+-      /* docs say this is const. if it changes, something else is 
+-       * broken. -pegasus
+-       */
+-      sa.sa_handler = &signal_handler;
+-      /* end possibly risky code */
+-      for (sig_no = 0; sig_no < NSIG; sig_no++)
+-      {
+-              signal_handlers[sig_no] = NULL;
+-              /* this is ugly, but the `correct' way.  i hate c. -mrg */
+-              /* moved from my_signal. -pegasus */
+-              sa.sa_flags = 0;
++      if (sig_no < 0)
++              return NULL;                    /* Signal not implemented */
++
++      signal_handlers[sig_no] = NULL;
++
++      sa.sa_handler = sig_handler;
++      sigemptyset(&sa.sa_mask);
++      sigaddset(&sa.sa_mask, sig_no);
++
++      /* this is ugly, but the `correct' way.  i hate c. -mrg */
++      sa.sa_flags = 0;
+ #if defined(SA_RESTART) || defined(SA_INTERRUPT)
+-              if (SIGALRM == sig_no || SIGINT == sig_no)
+-              {
++      if (SIGALRM == sig_no || SIGINT == sig_no)
++      {
+ # if defined(SA_INTERRUPT)
+-                      sa.sa_flags |= SA_INTERRUPT;
++              sa.sa_flags |= SA_INTERRUPT;
+ # endif /* SA_INTERRUPT */
+-              }
+-              else
+-              {
++      }
++      else
++      {
+ # if defined(SA_RESTART)
+-                      sa.sa_flags |= SA_RESTART;
++              sa.sa_flags |= SA_RESTART;
+ # endif /* SA_RESTART */
+-              }
++      }
+ #endif /* SA_RESTART || SA_INTERRUPT */
+-              /* if it wasn't for the above code, we could move the
+-               * sigemptyset() and sigaction() calls outside the loop 
+-               * proper. -pegasus
+-               */
+-              sigemptyset(&sa.sa_mask);
+-              sigaddset(&sa.sa_mask, sig_no);
+-              if (0 > sigaction(sig_no, &sa, &osa))
++
++      if (0 > sigaction(sig_no, &sa, &osa))
++              return SIG_ERR;
++
++      return osa.sa_handler;
++}
++
++
++/* hook_all_signals needs to be called in main() before my_signal()
++ * if any signal hooks fail, it returns SIG_ERR, otherwise it returns
++ * NULL. - pegasus
++ */
++sigfunc *     init_signals (void)
++{
++      int sig_no;
++      sigfunc *error = NULL;
++
++      memset(&signals_caught, 0, NSIG * sizeof(int));
++
++      for (sig_no = 0; sig_no < NSIG; sig_no++)
++      {
++              if ((reset_one_signal(sig_no, signal_handler)) == SIG_ERR)
+                       error = SIG_ERR;
+       }
+       return error;
+ }
+ 
+-sigfunc *my_signal (int sig_no, sigfunc *sig_handler)
++sigfunc *     my_signal (int sig_no, sigfunc *sig_handler)
+ {
+-        sigfunc *old;
++      sigfunc *old;
+ 
+-      if (sig_no < 0)
+-              return NULL;            /* Signal not implemented */
+-
+-      /* Well this is certainly simpler. -pegasus */
+       old = signal_handlers[sig_no];
+-      signal_handlers[sig_no] = (volatile sigfunc *)sig_handler;
++      if (sig_handler == SIG_IGN || sig_handler == SIG_DFL)
++              reset_one_signal(sig_no, sig_handler);
++      else
++      {
++              reset_one_signal(sig_no, signal_handler);
++              signal_handlers[sig_no] = (sigfunc *)sig_handler;
++      }
+ 
+-        return old;
++      return old;
+ }

Reply via email to