Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Wordcode functions with empty bodies



> Continue, it hits endtrapscode() and from there
> frees the eprog in sigfuncs[28]. BUT it doesn't reset sigfuncs[28].

Oh, I see, sorry.  The answer is it should disappear from there at the
point where it would do with an ordinary (non-function) trap.  The value is
passed back because it may still be required as a function node in its
other guise --- that came out of the previous set of fixes to local traps.

Ideally this value shouldn't be used anyway, because sigtrapped[SIGWINCH]
is now clear.  That was a problem in dosavetrap() --- it was correct to
save the trap, because it needs something to prompt it to delete the local
trap even if it just unsets it, but it should have checked sigtrapped to
see if the sigfuncs value was valid.  I've also stuck in a DPUTS there to
see if the invalid combination ever comes up.

In principle, the trap test should already pick this sort of thing up, it
just didn't crash often enough.  More DPUTS()'s are probably the answer to
similar future problems.

It would probably be better to rewrite the code so that trap functions are
never recorded in sigfuncs, just as a flag in sigtrapped, and always taken
from the functions hash when needed.

Index: Src/signals.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/signals.c,v
retrieving revision 1.8
diff -u -r1.8 signals.c
--- Src/signals.c	2000/06/14 14:19:20	1.8
+++ Src/signals.c	2000/06/14 15:06:43
@@ -671,8 +671,11 @@
 	    newshf->funcdef = dupeprog(shf->funcdef, 0);
 	}
 	st->list = newshf;
-    } else {
+    } else if (sigtrapped[sig]) {
 	st->list = sigfuncs[sig] ? dupeprog(sigfuncs[sig], 0) : NULL;
+    } else {
+	DPUTS(sigfuncs[sig], "BUG: sigfuncs not null for untrapped signal");
+	st->list = NULL;
     }
     if (!savetraps)
 	savetraps = znewlinklist();
@@ -789,6 +792,7 @@
 	 * As in dosavetrap(), don't call removeshfuncnode() because
 	 * that calls back into unsettrap();
 	 */
+	sigfuncs[sig] = NULL;
 	return removehashnode(shfunctab, func);
     } else if (sigfuncs[sig]) {
 	freeeprog(sigfuncs[sig]);

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxxx>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070



Messages sorted by: Reverse Date, Date, Thread, Author