rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
From: netapp!byron@netcom.com (Byron Rakitzis)
To: rc@hawkwind.utcs.toronto.edu
Subject: ^C leak
Date: Sat, 15 Aug 1992 04:07:48 -0400	[thread overview]
Message-ID: <9208150807.AA18161@netapp.netapp> (raw)

It appears to be in yacc.

Some yacc's call malloc to create their token stack, while some yacc's
have a fixed stack size. Now, rc calls yyparse which calls yylex which
calls read. An interrupt in read causes the signal to be trapped before
any more tokens can be returned to yacc so that it may either call
YYABORT or YYACCEPT (the two macros which also free up the yacc stack
space).

Obviously, the reason why the leak is not apparent at any time but when
a command is being typed is because the interrupt must occur while yacc
is active.

I would argue that this is a bug in yacc, given that it's extremely
difficult, if not impossible, to do exception processing given this
model. Perhaps yacc should supply a callback function to free memory,
or perhaps it should not call malloc in the first place. I'll see what
I can do about working around this. The fix is probably odious:
exception handling will have to be context-sensitive ("are we in a
stack frame containing yyparse?") and there will have to be some
automagical way of simulating a ^C through yacc. As I said, I don't
know if it's possible to fix.

In the meantime, you can always get rid of the leak by compiling rc
with a yacc that does not use malloc.  (old berkeley yacc is definitely
one of these, and it's probably in the bsd-sources tree. I got my
y.tab.c from a NeXT running such a yacc)

Depressing, eh? Does anyone have any better ideas?


             reply	other threads:[~1992-08-16  1:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-08-15  8:07 Byron Rakitzis [this message]
1992-08-16  1:32 ` Scott Schwartz

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=9208150807.AA18161@netapp.netapp \
    --to=netapp!byron@netcom.com \
    --cc=rc@hawkwind.utcs.toronto.edu \
    /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.
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).