comparison src/print.c @ 4880:ae81a2c00f4f

try harder to avoid crashing when debug-printing -------------------- ChangeLog entries follow: -------------------- src/ChangeLog addition: 2010-01-18 Ben Wing <ben@xemacs.org> * lisp.h: * print.c: New variable `in_debug_print'. * alloc.c: * alloc.c (free_managed_lcrecord): If gc_in_progress and in_debug_print, just return instead of crashing. This only happens when the programmer calls debug_print() or a variation inside of a debugger, and is probably already diagnosing a crash. * print.c (struct debug_bindings): * print.c (debug_prin1_exit): * print.c (debug_prin1): At entrance, record the old value of in_debug_print in the debug_bindings, set up an unwind-protect to restore the old value, and set in_debug_print to 1. In the unwind-protect, restore the old value.
author Ben Wing <ben@xemacs.org>
date Mon, 18 Jan 2010 06:05:21 -0600
parents 05c519de7353
children 19a72041c5ed
comparison
equal deleted inserted replaced
4879:c356806cc933 4880:ae81a2c00f4f
112 Lisp_Object Qprint_message_label; 112 Lisp_Object Qprint_message_label;
113 113
114 /* Force immediate output of all printed data. Used for debugging. */ 114 /* Force immediate output of all printed data. Used for debugging. */
115 int print_unbuffered; 115 int print_unbuffered;
116 116
117 /* Non-zero if in debug-printing */
118 int in_debug_print;
119
117 FILE *termscript; /* Stdio stream being used for copy of all output. */ 120 FILE *termscript; /* Stdio stream being used for copy of all output. */
118 121
119 static void write_string_to_alternate_debugging_output (const Ibyte *str, 122 static void write_string_to_alternate_debugging_output (const Ibyte *str,
120 Bytecount len); 123 Bytecount len);
121 124
125 { 128 {
126 int inhibit_non_essential_conversion_operations; 129 int inhibit_non_essential_conversion_operations;
127 int print_depth; 130 int print_depth;
128 int print_readably; 131 int print_readably;
129 int print_unbuffered; 132 int print_unbuffered;
133 int in_debug_print;
130 int gc_currently_forbidden; 134 int gc_currently_forbidden;
131 Lisp_Object Vprint_length; 135 Lisp_Object Vprint_length;
132 Lisp_Object Vprint_level; 136 Lisp_Object Vprint_level;
133 Lisp_Object Vinhibit_quit; 137 Lisp_Object Vinhibit_quit;
134 }; 138 };
2241 inhibit_non_essential_conversion_operations = 2245 inhibit_non_essential_conversion_operations =
2242 bindings->inhibit_non_essential_conversion_operations; 2246 bindings->inhibit_non_essential_conversion_operations;
2243 print_depth = bindings->print_depth; 2247 print_depth = bindings->print_depth;
2244 print_readably = bindings->print_readably; 2248 print_readably = bindings->print_readably;
2245 print_unbuffered = bindings->print_unbuffered; 2249 print_unbuffered = bindings->print_unbuffered;
2250 in_debug_print = bindings->in_debug_print;
2246 gc_currently_forbidden = bindings->gc_currently_forbidden; 2251 gc_currently_forbidden = bindings->gc_currently_forbidden;
2247 Vprint_length = bindings->Vprint_length; 2252 Vprint_length = bindings->Vprint_length;
2248 Vprint_level = bindings->Vprint_level; 2253 Vprint_level = bindings->Vprint_level;
2249 Vinhibit_quit = bindings->Vinhibit_quit; 2254 Vinhibit_quit = bindings->Vinhibit_quit;
2250 return Qnil; 2255 return Qnil;
2268 bindings->inhibit_non_essential_conversion_operations = 2273 bindings->inhibit_non_essential_conversion_operations =
2269 inhibit_non_essential_conversion_operations; 2274 inhibit_non_essential_conversion_operations;
2270 bindings->print_depth = print_depth; 2275 bindings->print_depth = print_depth;
2271 bindings->print_readably = print_readably; 2276 bindings->print_readably = print_readably;
2272 bindings->print_unbuffered = print_unbuffered; 2277 bindings->print_unbuffered = print_unbuffered;
2278 bindings->in_debug_print = in_debug_print;
2273 bindings->gc_currently_forbidden = gc_currently_forbidden; 2279 bindings->gc_currently_forbidden = gc_currently_forbidden;
2274 bindings->Vprint_length = Vprint_length; 2280 bindings->Vprint_length = Vprint_length;
2275 bindings->Vprint_level = Vprint_level; 2281 bindings->Vprint_level = Vprint_level;
2276 bindings->Vinhibit_quit = Vinhibit_quit; 2282 bindings->Vinhibit_quit = Vinhibit_quit;
2277 specdepth = record_unwind_protect (debug_prin1_exit, Qnil); 2283 specdepth = record_unwind_protect (debug_prin1_exit, Qnil);
2278 2284
2279 inhibit_non_essential_conversion_operations = 1; 2285 inhibit_non_essential_conversion_operations = 1;
2280 print_depth = 0; 2286 print_depth = 0;
2281 print_readably = debug_print_readably != -1 ? debug_print_readably : 0; 2287 print_readably = debug_print_readably != -1 ? debug_print_readably : 0;
2282 print_unbuffered++; 2288 print_unbuffered++;
2289 in_debug_print = 1;
2290 gc_currently_forbidden = 1;
2283 if (debug_print_length > 0) 2291 if (debug_print_length > 0)
2284 Vprint_length = make_int (debug_print_length); 2292 Vprint_length = make_int (debug_print_length);
2285 if (debug_print_level > 0) 2293 if (debug_print_level > 0)
2286 Vprint_level = make_int (debug_print_level); 2294 Vprint_level = make_int (debug_print_level);
2287 Vinhibit_quit = Qt; 2295 Vinhibit_quit = Qt;