rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* ^C leak
@ 1992-08-15  8:07 Byron Rakitzis
  1992-08-16  1:32 ` Scott Schwartz
  0 siblings, 1 reply; 2+ messages in thread
From: Byron Rakitzis @ 1992-08-15  8:07 UTC (permalink / raw)
  To: rc

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?


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: ^C leak
  1992-08-15  8:07 ^C leak Byron Rakitzis
@ 1992-08-16  1:32 ` Scott Schwartz
  0 siblings, 0 replies; 2+ messages in thread
From: Scott Schwartz @ 1992-08-16  1:32 UTC (permalink / raw)
  To: Byron Rakitzis; +Cc: rc


I suggest not altering rc unnecessarily.  Given that there are lots of
yacc implementations floating around, including a public domain one
from corbett@berkeley.edu, you might as well just tell people to use
one of those.  If you ship a y.tab.[ch] with rc, it may not be
necessary to run yacc at all.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1992-08-16  1:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1992-08-15  8:07 ^C leak Byron Rakitzis
1992-08-16  1:32 ` Scott Schwartz

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).