From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8139 invoked from network); 14 Jun 2000 15:09:13 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 14 Jun 2000 15:09:13 -0000 Received: (qmail 26597 invoked by alias); 14 Jun 2000 15:09:07 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 11901 Received: (qmail 26590 invoked from network); 14 Jun 2000 15:09:07 -0000 Date: Wed, 14 Jun 2000 16:08:40 +0100 From: Peter Stephenson Subject: Re: Wordcode functions with empty bodies In-reply-to: "Your message of Wed, 14 Jun 2000 16:28:21 +0200." <200006141428.QAA03707@beta.informatik.hu-berlin.de> To: zsh-workers@sunsite.auc.dk (Zsh hackers list) Message-id: <0FW500762GQFIK@la-la.cambridgesiliconradio.com> Content-transfer-encoding: 7BIT > 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 Cambridge Silicon Radio, Unit 300, Science Park, Milton Road, Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070