Mercurial > hg > xemacs-beta
comparison src/alloc.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 | 5d120deb60ca |
children | 6ef8256a020a 714f7c9fabb1 |
comparison
equal
deleted
inserted
replaced
4879:c356806cc933 | 4880:ae81a2c00f4f |
---|---|
1 /* Storage allocation and gc for XEmacs Lisp interpreter. | 1 /* Storage allocation and gc for XEmacs Lisp interpreter. |
2 Copyright (C) 1985-1998 Free Software Foundation, Inc. | 2 Copyright (C) 1985-1998 Free Software Foundation, Inc. |
3 Copyright (C) 1995 Sun Microsystems, Inc. | 3 Copyright (C) 1995 Sun Microsystems, Inc. |
4 Copyright (C) 1995, 1996, 2001, 2002, 2003, 2004, 2005 Ben Wing. | 4 Copyright (C) 1995, 1996, 2001, 2002, 2003, 2004, 2005, 2010 Ben Wing. |
5 | 5 |
6 This file is part of XEmacs. | 6 This file is part of XEmacs. |
7 | 7 |
8 XEmacs is free software; you can redistribute it and/or modify it | 8 XEmacs is free software; you can redistribute it and/or modify it |
9 under the terms of the GNU General Public License as published by the | 9 under the terms of the GNU General Public License as published by the |
3114 struct free_lcrecord_header *free_header = | 3114 struct free_lcrecord_header *free_header = |
3115 (struct free_lcrecord_header *) XPNTR (lcrecord); | 3115 (struct free_lcrecord_header *) XPNTR (lcrecord); |
3116 struct lrecord_header *lheader = &free_header->lcheader.lheader; | 3116 struct lrecord_header *lheader = &free_header->lcheader.lheader; |
3117 const struct lrecord_implementation *implementation | 3117 const struct lrecord_implementation *implementation |
3118 = LHEADER_IMPLEMENTATION (lheader); | 3118 = LHEADER_IMPLEMENTATION (lheader); |
3119 | |
3120 /* If we try to debug-print during GC, we'll likely get a crash on the | |
3121 following assert (called from Lstream_delete(), from prin1_to_string()). | |
3122 Instead, just don't do anything. Worst comes to worst, we have a | |
3123 small memory leak -- and programs being debugged usually won't be | |
3124 super long-lived afterwards, anyway. */ | |
3125 if (gc_in_progress && in_debug_print) | |
3126 return; | |
3119 | 3127 |
3120 /* Finalizer methods may try to free objects within them, which typically | 3128 /* Finalizer methods may try to free objects within them, which typically |
3121 won't be marked and thus are scheduled for demolition. Putting them | 3129 won't be marked and thus are scheduled for demolition. Putting them |
3122 on the free list would be very bad, as we'd have xfree()d memory in | 3130 on the free list would be very bad, as we'd have xfree()d memory in |
3123 the list. Even if for some reason the objects are still live | 3131 the list. Even if for some reason the objects are still live |