GNU bug report logs -
#16576
Binding `standard-output' to a function doesn't work -- function sometimes called with garbage
Previous Next
Full log
Message #22 received at 16576-done <at> debbugs.gnu.org (full text, mbox):
> Date: Tue, 28 Jan 2014 23:00:32 +0100
> From: Anders Lindgren <andlind <at> gmail.com>
> Cc: 16576 <at> debbugs.gnu.org
>
> Well, the main issue here is if this is a real bug or not. You originally
> thought this was simply a mistake in the example I provided -- do you still
> think so?
There was indeed a bug, now fixed on the trunk, which caused the
problem. It was a very old bug, it went unnoticed until now because,
I guess, no one conses a string one character at a time -- this is a
terrible idea in Emacs Lisp. Use a temporary buffer instead.
There was nothing wrong with prin1 per se, btw, it's just that its
subroutine which prints a string wasn't safe when GC hit in the middle
of a prin1 call. The code protected the string from GC, but that
doesn't preclude relocation of string data, so holding to C 'char *'
pointers is not safe in these situations. And printing a
800-character string like you did triggers GC every time, because it
creates 800 string objects for a grand total of about 320000 bytes.
Anyway, problem solved, and I'm closing the bug. Thanks.
This bug report was last modified 11 years and 108 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.