From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs 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 Message-ID: <83wqhi7jl6.fsf@gnu.org> References: <83ob2w85d3.fsf@gnu.org> <834n4n97lo.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1391018593 18363 80.91.229.3 (29 Jan 2014 18:03:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 29 Jan 2014 18:03:13 +0000 (UTC) Cc: 16576-done@debbugs.gnu.org To: Anders Lindgren Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jan 29 19:03:19 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1W8ZTq-00045n-GC for geb-bug-gnu-emacs@m.gmane.org; Wed, 29 Jan 2014 19:03:18 +0100 Original-Received: from localhost ([::1]:44307 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8ZTq-0006o8-4O for geb-bug-gnu-emacs@m.gmane.org; Wed, 29 Jan 2014 13:03:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60169) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8ZTh-0006kg-VU for bug-gnu-emacs@gnu.org; Wed, 29 Jan 2014 13:03:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8ZTc-0007zi-5Z for bug-gnu-emacs@gnu.org; Wed, 29 Jan 2014 13:03:09 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:54729) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8ZTc-0007zP-2I for bug-gnu-emacs@gnu.org; Wed, 29 Jan 2014 13:03:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1W8ZTb-0005N1-In for bug-gnu-emacs@gnu.org; Wed, 29 Jan 2014 13:03:03 -0500 Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Wed, 29 Jan 2014 18:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 16576 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Mail-Followup-To: 16576@debbugs.gnu.org, eliz@gnu.org, andlind@gmail.com Original-Received: via spool by 16576-done@debbugs.gnu.org id=D16576.139101852420556 (code D ref 16576); Wed, 29 Jan 2014 18:03:02 +0000 Original-Received: (at 16576-done) by debbugs.gnu.org; 29 Jan 2014 18:02:04 +0000 Original-Received: from localhost ([127.0.0.1]:40514 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W8ZSd-0005LT-Gy for submit@debbugs.gnu.org; Wed, 29 Jan 2014 13:02:03 -0500 Original-Received: from mtaout25.012.net.il ([80.179.55.181]:48498) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W8ZSa-0005Kx-9P for 16576-done@debbugs.gnu.org; Wed, 29 Jan 2014 13:02:01 -0500 Original-Received: from conversion-daemon.mtaout25.012.net.il by mtaout25.012.net.il (HyperSendmail v2007.08) id <0N0600F00CIKK300@mtaout25.012.net.il> for 16576-done@debbugs.gnu.org; Wed, 29 Jan 2014 20:01:32 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by mtaout25.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0N06008QPCQJD680@mtaout25.012.net.il>; Wed, 29 Jan 2014 20:01:31 +0200 (IST) In-reply-to: X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:84222 Archived-At: > Date: Tue, 28 Jan 2014 23:00:32 +0100 > From: Anders Lindgren > Cc: 16576@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.