all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Anders Lindgren <andlind@gmail.com>
Cc: 16576-done@debbugs.gnu.org
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	[thread overview]
Message-ID: <83wqhi7jl6.fsf@gnu.org> (raw)
In-Reply-To: <CABr8ebatX1Rq+==w=a0baKwgCkuSF0dhVudwmrr-L9cHvZ15Nw@mail.gmail.com>

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





  reply	other threads:[~2014-01-29 18:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-28  9:09 bug#16576: Binding `standard-output' to a function doesn't work -- function sometimes called with garbage Anders Lindgren
2014-01-28 15:59 ` Eli Zaretskii
2014-01-28 19:39   ` Anders Lindgren
2014-01-28 20:25     ` Eli Zaretskii
2014-01-28 22:00       ` Anders Lindgren
2014-01-29 18:01         ` Eli Zaretskii [this message]
2014-01-29 21:12           ` Anders Lindgren
2014-01-30  0:38             ` Stefan Monnier
2014-01-31 16:20               ` Anders Lindgren
2014-01-31 21:04                 ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83wqhi7jl6.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=16576-done@debbugs.gnu.org \
    --cc=andlind@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.