[PATCH 21.5] Bind print-circle when printing backtraces
Jerry James <[email protected]>
| Newsgroups | gmane.emacs.xemacs.patches |
|---|---|
| Message-ID | <CAHCOHQkhpgXZFH5pWAEzdkzVsbAeQqCpNAKsFte1pX8Fv5FjNA@mail.gmail.com> |
PATCH 21.5 Yesterday, I received a bug report filed against the Fedora XFT build of XEmacs. (The default build is non-XFT, for the curious.) This bug report shows at least two bugs. This patch addresses the first. The XFT build segfaults (looks like a NULL pointer gets passed to FCPatternObjectAddWithBinding), and tries to print a backtrace. But the backtrace printing gets into an infinite loop and blows the stack, like this (line numbers translated to current Mercurial head): 1. debug_backtrace: print.c, line 3089 2. Fbacktrace: eval.c, line 7216 3. Fprin1: print.c, line 1128 4. print_internal: print.c, line 2507 5. print_compiled_function: bytecode.c, line 2339 6. print_internal: print.c, line 2507 7. print_vector_internal: print.c, line 1600 8. goto #4 Apparently, the way we print compiled functions includes printing some internal vector, which includes a pointer back to the compiled function. Here is a portion of the output that XEmacs generates before it explodes, with some whitespace changes for readability: #<compiled-function (from "/builddir/build/BUILD/xemacs-21.5.34/lisp/faces.elc") (locale inst-list prop devtype-spec) "...(264)" [#:G23465 devtype #:G23464 devtype-spec tag-set x nil derive-device-type-from-locale-and-tag-set functionp plist-get error unimplemented "mapper" vectorp assoc t 1 #<compiled-function ... I don't understand that part, but it seems like binding print-circle while printing a backtrace would be a good idea in any case. That is what this patch does. diff -r 2d20d57d4e7b src/ChangeLog --- a/src/ChangeLog Wed May 07 13:33:50 2014 -0600 +++ b/src/ChangeLog Thu May 08 08:51:32 2014 -0600 @@ -1,3 +1,9 @@ +2014-05-08 Jerry James <[email protected]> + + * print.c (struct debug_bindings): Add print_circle field. + (debug_print_exit): Restore print_circle. + (debug_print_enter): Save print_circle binding and set it. + 2014-01-27 Michael Sperber <[email protected]> * symbols.c (Fdefine_function): Allow optional `docstring' diff -r 2d20d57d4e7b src/print.c --- a/src/print.c Wed May 07 13:33:50 2014 -0600 +++ b/src/print.c Thu May 08 08:51:32 2014 -0600 @@ -164,6 +164,7 @@ int print_depth; int print_readably; int print_unbuffered; + int print_circle; int in_debug_print; int gc_currently_forbidden; Lisp_Object Vprint_length; @@ -2847,6 +2848,7 @@ print_depth = bindings->print_depth; print_readably = bindings->print_readably; print_unbuffered = bindings->print_unbuffered; + print_circle = bindings->print_circle; in_debug_print = bindings->in_debug_print; gc_currently_forbidden = bindings->gc_currently_forbidden; Vprint_length = bindings->Vprint_length; @@ -2873,6 +2875,7 @@ bindings->print_depth = print_depth; bindings->print_readably = print_readably; bindings->print_unbuffered = print_unbuffered; + bindings->print_circle = print_circle; bindings->in_debug_print = in_debug_print; bindings->gc_currently_forbidden = gc_currently_forbidden; bindings->Vprint_length = Vprint_length; @@ -2885,6 +2888,7 @@ print_depth = 0; print_readably = debug_print_readably != -1 ? debug_print_readably : 0; print_unbuffered++; + print_circle = 1; in_debug_print = 1; gc_currently_forbidden = 1; if (debug_print_length > 0) -- Jerry James http://www.jamezone.org/