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

A bug

I just spent some time trying to sort out an obscure bug. Repeatedly
for no reason, the shell would hang. Gdb revealed it was hanging in
the run-time report code, any program taking longer than 10 seconds
(REPORTTIME) were hanging....

The reason? Had me beat. :-)

Everything seemed to be behaving, and if I gdb'd it under emacs, the
problem didn't even turn up! However, this problem "just started
happening", and one of the things I have been doing recently is
modifying terminal description files. Termcap entries are by
definition restricted to 1024 bytes, and my terminal termcap entry had
crept over the limit. The old buffer overrun joke.

So whos fault was it? (apart from mine. :-)

Well, libtermcap really, but then libtermcap was probably just trying
to be helpful and give away all the information it had.

So why am I telling you this? Mainly as a warning that this is a
source of obscure bug behaviour. I'm not sure it deserves to go in
the FAQ, I doubt it turns up very often. And it isn't easy to fix,
except to move to curses/terminfo :-). A temporary large buffer copied
to a "correct" sized buffer would be more robust, but only until you
get a REALLY oversized termcap entry.

ps: There's a potential problem if the last character of TIMEFMT is a
'%', being that the null terminator gets printed, and the characters
_after_ the terminator get parsed. Of course, the next character is
nearly always a null anyway.

I know, I know.... I just happened to be looking at the code though. :-)

diff against beta10. Changes TIMEFMT semantics in a very uninteresting
way. '%%x' now prints '%' and parses '%x' instead of printing '%%' and
parsing 'x'. Probably '%%' should really print a single '%', which is
different again!

*** jobs.c.orig	Mon Oct 16 21:01:57 1995
--- jobs.c	Mon Oct 16 21:06:26 1995
*** 732,738 ****
  		fprintf(stderr, "%s", desc);
! 		fprintf(stderr, "%%%c", *s);
  	} else
  	    putc(*s, stderr);
--- 732,739 ----
  		fprintf(stderr, "%s", desc);
! 		putc('%', stderr);
! 		s--;
  	} else
  	    putc(*s, stderr);

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