bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#16576: Binding `standard-output' to a function doesn't work -- funct


From: Eli Zaretskii
Subject: bug#16576: Binding `standard-output' to a function doesn't work -- function sometimes called with garbage
Date: Wed, 29 Jan 2014 20:01:57 +0200

> Date: Tue, 28 Jan 2014 23:00:32 +0100
> From: Anders Lindgren <address@hidden>
> Cc: address@hidden
> 
> 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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]