From cfb2f32e41fd97d98129f6bc17991d1b7a906a47 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 23 Jan 2006 02:35:36 +0000 Subject: (lisp_align_free): Add an assertion. (make_interval, allocate_string, make_float, allocate_misc, Fmake_symbol (Fcons): If ENABLE_CHECKING is on, check we're not called from a sighandler. --- src/alloc.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 96934269d23..d81a9bf853b 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -1,6 +1,6 @@ /* Storage allocation and gc for GNU Emacs Lisp interpreter. Copyright (C) 1985, 1986, 1988, 1993, 1994, 1995, 1997, 1998, 1999, - 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -1105,6 +1105,9 @@ lisp_align_free (block) } eassert ((aligned & 1) == aligned); eassert (i == (aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1)); +#ifdef HAVE_POSIX_MEMALIGN + eassert ((unsigned long)ABLOCKS_BASE (abase) % BLOCK_ALIGN == 0); +#endif free (ABLOCKS_BASE (abase)); } UNBLOCK_INPUT; @@ -1419,6 +1422,8 @@ make_interval () { INTERVAL val; + eassert (!handling_signal); + if (interval_free_list) { val = interval_free_list; @@ -1837,6 +1842,8 @@ allocate_string () { struct Lisp_String *s; + eassert (!handling_signal); + /* If the free-list is empty, allocate a new string_block, and add all the Lisp_Strings in it to the free-list. */ if (string_free_list == NULL) @@ -2552,6 +2559,8 @@ make_float (float_value) { register Lisp_Object val; + eassert (!handling_signal); + if (float_free_list) { /* We use the data field for chaining the free list @@ -2671,6 +2680,8 @@ DEFUN ("cons", Fcons, Scons, 2, 2, 0, { register Lisp_Object val; + eassert (!handling_signal); + if (cons_free_list) { /* We use the cdr for chaining the free list @@ -2852,6 +2863,9 @@ allocate_vectorlike (len, type) UNBLOCK_INPUT; #endif + /* This gets triggered by code which I haven't bothered to fix. --Stef */ + /* eassert (!handling_signal); */ + nbytes = sizeof *p + (len - 1) * sizeof p->contents[0]; p = (struct Lisp_Vector *) lisp_malloc (nbytes, type); @@ -3145,6 +3159,8 @@ Its value and function definition are void, and its property list is nil. */) CHECK_STRING (name); + eassert (!handling_signal); + if (symbol_free_list) { XSETSYMBOL (val, symbol_free_list); @@ -3225,6 +3241,8 @@ allocate_misc () { Lisp_Object val; + eassert (!handling_signal); + if (marker_free_list) { XSETMISC (val, marker_free_list); -- cgit v1.2.1 From a0b08700d1a0affe59ce2428cc8d204362924ad7 Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Tue, 24 Jan 2006 18:35:25 +0000 Subject: * alloc.c (allocate_string_data): Update next_free immediately, to reduce risk of memory clobberage. --- src/alloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index d81a9bf853b..f0c77a26710 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -1978,6 +1978,8 @@ allocate_string_data (s, nchars, nbytes) old_nbytes = GC_STRING_BYTES (s); data = b->next_free; + b->next_free = (struct sdata *) ((char *) data + needed + GC_STRING_EXTRA); + data->string = s; s->data = SDATA_DATA (data); #ifdef GC_CHECK_STRING_BYTES @@ -1990,7 +1992,6 @@ allocate_string_data (s, nchars, nbytes) bcopy (string_overrun_cookie, (char *) data + needed, GC_STRING_OVERRUN_COOKIE_SIZE); #endif - b->next_free = (struct sdata *) ((char *) data + needed + GC_STRING_EXTRA); /* If S had already data assigned, mark that as free by setting its string back-pointer to null, and recording the size of the data -- cgit v1.2.1