all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Seweryn <sewkokot@gmail.com>
To: emacs-devel@gnu.org
Subject: Re: &quot;Apparently circular structure being printed&quot;
Date: Tue, 9 Nov 2010 07:49:43 +0000 (UTC)	[thread overview]
Message-ID: <loom.20101109T083926-875@post.gmane.org> (raw)
In-Reply-To: 87iq07wfus.fsf@sysu76.podval.org

Sam Steingold <sds <at> gnu.org> writes:

> 
> GNU Emacs 24.0.50.4 (x86_64-unknown-linux-gnu, GTK+ Version 2.20.1)
>  of 2010-11-07 on sysu76
>  '--with-x-toolkit=gtk'
> 
> In an nXML buffer:
> C-h v rng-compile-table RET
> 
> I get an error in the *Messages* buffer:
> 
> Entering debugger...
> debugger-setup-buffer: Apparently circular structure being printed
> 
> no *Backtrace* buffer is created.
> my print-circle is t.
> 

I get the same error with predictive package [1].

Here are steps to reproduce it:
1) Open an arbitrary text file.txt
2) M-x predictive-mode (my rpg-dictionary is loaded)
3) predictive-add-to-dict <- "Very longgggggg string"
(I want to add the expression in qutes, of course without quotes)
4) predictive-save-dict (OK)
5) predictive-add-to-dict <- "Very veryyyyyy longggggggggggggg stringgggggggg"
6) I get the message in echo area: "Entering debugger...
debugger-setup-buffer: Apparently circular structure being printed"
7) No *Backtrace*

The Author of predictive package wrote me as follows:

"This enabled me to reproduce the issue, and I
remember now what it is that causes this. It has nothing to do with
special characters (the predictive-mode dictionaries can store arbitrary
strings). It's to do with the *length* of the string you're trying to
store.

Unfortunately, Emacs has an undocumented, hard-coded limit on the depth
of a Lisp list structure, beyond which it considers the structure to be
circular and refuses to print it, throwing the "Apparently circular
structure" error. This limit only applies to printing such structures;
Emacs will happily work with deeply nested structures in all other
circumstances. But predictive-mode uses the Lisp printing functions to
write the dictionaries to file, hence the error when saving.

It's not unreasonable to impose a depth limit on printing, as it guards
against hanging in a tight loop if you inadvertently ask Emacs to
printing a circular list structure. However, it's unfortunate that this
limit is hard-coded. Other similar Emacs limits can be changed by
modifying a variable in Elisp, but not this one. The vast majority of
Elisp code only uses very simple data structures, and the Emacs devs
didn't have predictive-mode in mind when they arbitrarily chose the value
for this print-depth limit, so it's set rather conservatively.

The practical consequence is that standard Emacs will bork on saving
dictionaries containing strings longer than about 45 characters. There is
a patch included in the predictive package (print.c.diff) [2] which increases
this limit by a factor of 5. (If you envisage storing even longer
strings, you could increase this even further. The required modification
should be obvious from the patch file.) But obviously this requires
patching and compiling the Emacs source yourself, which is possible but
maybe not so easy under Windows."

Regards,
Seweryn


[1] http://www.emacswiki.org/emacs/PredictiveMode or
http://www.dr-qubit.org/emacs.php#predictive

[2]
<code>
--- print.c	2008-10-24 11:18:33.000000000 +0100
+++ print.c.new	2008-10-24 11:19:27.000000000 +0100
@@ -88,7 +88,7 @@
 int new_backquote_output;
 
 /* Detect most circularities to print finite output.  */
-#define PRINT_CIRCLE 200
+#define PRINT_CIRCLE 1000
 Lisp_Object being_printed[PRINT_CIRCLE];
 
 /* When printing into a buffer, first we put the text in this
</code>




  reply	other threads:[~2010-11-09  7:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-08 23:33 "Apparently circular structure being printed" Sam Steingold
2010-11-09  7:49 ` Seweryn [this message]
2010-11-09 20:11   ` &amp; quot; Apparently circular structure being printed&amp; quot; Seweryn

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=loom.20101109T083926-875@post.gmane.org \
    --to=sewkokot@gmail.com \
    --cc=emacs-devel@gnu.org \
    /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.