GNU bug report logs -
#55481
mostly nonrecursive printing [PATCH]
Previous Next
Reported by: Mattias Engdegård <mattiase <at> acm.org>
Date: Tue, 17 May 2022 14:00:02 UTC
Severity: normal
Tags: patch
Done: Mattias Engdegård <mattiase <at> acm.org>
Bug is archived. No further changes may be made.
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Printing deeply nested values typically crashes Emacs by running out of C stack since the printer uses C recursion to traverse nested data structures. This is a long-standing problem that keeps turning up; see bug#52753 for one example.
The attached patch eliminates most of the recursion: conses, vectors, records, hash tables and char tables are now traversed without consuming C stack. This should cover the vast majority of objects that form deep structures.
Of note:
- Performance seems to be slightly improved (about 2.5 % faster for printing a long list of symbols) but that's not really the point of the patch.
- The patch does not attempt to fix the bogus #N notation for circular lists (bug#55395) but tries to stay bug-compatible for easier comparison.
- Some special syntax is context-conditional: (\, X) is only printed as ,X if surrounded by a positive number of backquote forms. It's not clear what we gain from this; using the special syntax for the backquote, comma and comma-at forms unconditionally would simplify matter without any apparent inconvenience to the user. Right now, the patch does not remove recursion for printing these forms.
- This patch does not address reading nested values, where a similar problem exists.
[print-nonrec.diff (application/octet-stream, attachment)]
This bug report was last modified 3 years and 6 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.