zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: zsh-workers@sunsite.auc.dk
Subject: Re: BUG: permanent allocation in mathevall
Date: Sun, 26 Sep 1999 16:02:13 +0200	[thread overview]
Message-ID: <9909261402.AA16846@ibmth.df.unipi.it> (raw)
In-Reply-To: ""Bart Schaefer""'s message of "Sat, 25 Sep 1999 03:49:02 DFT." <990925034902.ZM29518@candle.brasslantern.com>

"Bart Schaefer" wrote:
> I'm getting the "BUG: permanent allocation in mathevall" message every time
> my TRAPALRM function fires.
> 
> TRAPALRM () {
>         TMOUT=60 
>         title
> }
> 
> It's happening below getiparam("TMOUT"):
> 
> Unfortunately, I'm not sure what to do about it.  I believe signal handlers
> deliberately avoid using the heap because of issues about when it should be
> popped, but I don't recall for certain.

It doesn't seem to be happening with TRAPUSR1, though: compare

TRAPUSR1() { integer i; i=4; print i is $i; }
kill -USR1 $$

with the same function as TRAPALRM with a non-zero timeout.  Slightly odd.

The easiest thing to do is to make user mathparse() gets called from
mathevall() with heap allocation.  It would be easy to write a heap-only
version of dupstring(), in fact I would feel a lot happier if there was
such a version, since dupstring() is almost always called with no intention
of every freeing the space.  However, the heap-alloced linked list for the
function call rather sets the cat among the pigeons.  We could zalloc() and
free that, of course.  With both these changes math evaluation would be
independent of allocation strategy, apart from possible problems with calls
into the parameter code, so maybe that's the right thing to do and this is
just too lazy.

There's an ancient issue with traps which has been in the back of mind for
years:  it would be much safer not to run them asynchronously at arbitrary
points, but to set a flag and call the trap at one of several strategic
points, e.g. after a foreground command has run or when an editor read is
interrupted.  This would mean traps not being run during a foreground
programme, I don't know how many people that would inconvenience.  We had
some of this discussion a long time ago.

--- Src/math.c.bak	Thu Sep 23 15:42:20 1999
+++ Src/math.c	Sun Sep 26 15:54:54 1999
@@ -852,7 +852,6 @@
     struct mathvalue *xstack = 0, nstack[STACKSZ];
     mnumber ret;
 
-    MUSTUSEHEAP("mathevall");
     if (mlevel++) {
 	xlastbase = lastbase;
 	xnoeval = noeval;
@@ -875,7 +874,9 @@
     ptr = s;
     sp = -1;
     unary = 1;
-    mathparse(prek);
+    HEAPALLOC {
+	mathparse(prek);
+    } LASTALLOC;
     *ep = ptr;
     DPUTS(!errflag && sp,
 	  "BUG: math: wallabies roaming too freely in outback");

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


  reply	other threads:[~1999-09-26 14:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-25  3:49 Bart Schaefer
1999-09-26 14:02 ` Peter Stephenson [this message]
1999-09-26 17:21   ` Bart Schaefer
1999-09-26 16:59     ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9909261402.AA16846@ibmth.df.unipi.it \
    --to=pws@ibmth.df.unipi.it \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).