diff options
| author | Paul Eggert | 2019-07-21 12:31:51 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-07-21 12:32:16 -0700 |
| commit | 5d4dd552c29279b8a9e6ed269a2dc3afc36f73b9 (patch) | |
| tree | 95edeff83e756072c35f974f6271ba8c191d8436 /src | |
| parent | d02c2f7f6507105605ed0596a7e26acd5b3b8122 (diff) | |
| download | emacs-5d4dd552c29279b8a9e6ed269a2dc3afc36f73b9.tar.gz emacs-5d4dd552c29279b8a9e6ed269a2dc3afc36f73b9.zip | |
Fix lifetime error in previous patch
Problem reported by Pip Cet in:
https://lists.gnu.org/r/emacs-devel/2019-07/msg00520.html
* src/alloc.c (inhibit_garbage_collection): Use new function.
(allow_garbage_collection): Accept intmax_t, not pointer.
* src/eval.c (default_toplevel_binding, do_one_unbind)
(backtrace_eval_unrewind, Fbacktrace__locals, mark_specpdl):
Support SPECPDL_UNWIND_INTMAX.
(record_unwind_protect_excursion): New function.
* src/lisp.h (enum specbind_tag): New constant SPECPDL_UNWIND_INTMAX.
(union specbinding): New member unwind_intmax.
Diffstat (limited to 'src')
| -rw-r--r-- | src/alloc.c | 8 | ||||
| -rw-r--r-- | src/eval.c | 16 | ||||
| -rw-r--r-- | src/lisp.h | 7 |
3 files changed, 26 insertions, 5 deletions
diff --git a/src/alloc.c b/src/alloc.c index 50015808e59..aa9200f2ebb 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -5505,10 +5505,9 @@ staticpro (Lisp_Object const *varaddress) | |||
| 5505 | consing_until_gc to speed up maybe_gc when GC is inhibited. */ | 5505 | consing_until_gc to speed up maybe_gc when GC is inhibited. */ |
| 5506 | 5506 | ||
| 5507 | static void | 5507 | static void |
| 5508 | allow_garbage_collection (void *ptr) | 5508 | allow_garbage_collection (intmax_t consing) |
| 5509 | { | 5509 | { |
| 5510 | object_ct *p = ptr; | 5510 | consing_until_gc = consing; |
| 5511 | consing_until_gc = *p; | ||
| 5512 | garbage_collection_inhibited--; | 5511 | garbage_collection_inhibited--; |
| 5513 | } | 5512 | } |
| 5514 | 5513 | ||
| @@ -5516,8 +5515,7 @@ ptrdiff_t | |||
| 5516 | inhibit_garbage_collection (void) | 5515 | inhibit_garbage_collection (void) |
| 5517 | { | 5516 | { |
| 5518 | ptrdiff_t count = SPECPDL_INDEX (); | 5517 | ptrdiff_t count = SPECPDL_INDEX (); |
| 5519 | object_ct consing = consing_until_gc; | 5518 | record_unwind_protect_intmax (allow_garbage_collection, consing_until_gc); |
| 5520 | record_unwind_protect_ptr (allow_garbage_collection, &consing); | ||
| 5521 | garbage_collection_inhibited++; | 5519 | garbage_collection_inhibited++; |
| 5522 | consing_until_gc = OBJECT_CT_MAX; | 5520 | consing_until_gc = OBJECT_CT_MAX; |
| 5523 | return count; | 5521 | return count; |
diff --git a/src/eval.c b/src/eval.c index 02a6c3555a9..b890aa6f7f2 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -674,6 +674,7 @@ default_toplevel_binding (Lisp_Object symbol) | |||
| 674 | case SPECPDL_UNWIND_ARRAY: | 674 | case SPECPDL_UNWIND_ARRAY: |
| 675 | case SPECPDL_UNWIND_PTR: | 675 | case SPECPDL_UNWIND_PTR: |
| 676 | case SPECPDL_UNWIND_INT: | 676 | case SPECPDL_UNWIND_INT: |
| 677 | case SPECPDL_UNWIND_INTMAX: | ||
| 677 | case SPECPDL_UNWIND_EXCURSION: | 678 | case SPECPDL_UNWIND_EXCURSION: |
| 678 | case SPECPDL_UNWIND_VOID: | 679 | case SPECPDL_UNWIND_VOID: |
| 679 | case SPECPDL_BACKTRACE: | 680 | case SPECPDL_BACKTRACE: |
| @@ -3395,6 +3396,15 @@ record_unwind_protect_int (void (*function) (int), int arg) | |||
| 3395 | } | 3396 | } |
| 3396 | 3397 | ||
| 3397 | void | 3398 | void |
| 3399 | record_unwind_protect_intmax (void (*function) (intmax_t), intmax_t arg) | ||
| 3400 | { | ||
| 3401 | specpdl_ptr->unwind_intmax.kind = SPECPDL_UNWIND_INTMAX; | ||
| 3402 | specpdl_ptr->unwind_intmax.func = function; | ||
| 3403 | specpdl_ptr->unwind_intmax.arg = arg; | ||
| 3404 | grow_specpdl (); | ||
| 3405 | } | ||
| 3406 | |||
| 3407 | void | ||
| 3398 | record_unwind_protect_excursion (void) | 3408 | record_unwind_protect_excursion (void) |
| 3399 | { | 3409 | { |
| 3400 | specpdl_ptr->unwind_excursion.kind = SPECPDL_UNWIND_EXCURSION; | 3410 | specpdl_ptr->unwind_excursion.kind = SPECPDL_UNWIND_EXCURSION; |
| @@ -3448,6 +3458,9 @@ do_one_unbind (union specbinding *this_binding, bool unwinding, | |||
| 3448 | case SPECPDL_UNWIND_INT: | 3458 | case SPECPDL_UNWIND_INT: |
| 3449 | this_binding->unwind_int.func (this_binding->unwind_int.arg); | 3459 | this_binding->unwind_int.func (this_binding->unwind_int.arg); |
| 3450 | break; | 3460 | break; |
| 3461 | case SPECPDL_UNWIND_INTMAX: | ||
| 3462 | this_binding->unwind_intmax.func (this_binding->unwind_intmax.arg); | ||
| 3463 | break; | ||
| 3451 | case SPECPDL_UNWIND_VOID: | 3464 | case SPECPDL_UNWIND_VOID: |
| 3452 | this_binding->unwind_void.func (); | 3465 | this_binding->unwind_void.func (); |
| 3453 | break; | 3466 | break; |
| @@ -3784,6 +3797,7 @@ backtrace_eval_unrewind (int distance) | |||
| 3784 | case SPECPDL_UNWIND_ARRAY: | 3797 | case SPECPDL_UNWIND_ARRAY: |
| 3785 | case SPECPDL_UNWIND_PTR: | 3798 | case SPECPDL_UNWIND_PTR: |
| 3786 | case SPECPDL_UNWIND_INT: | 3799 | case SPECPDL_UNWIND_INT: |
| 3800 | case SPECPDL_UNWIND_INTMAX: | ||
| 3787 | case SPECPDL_UNWIND_VOID: | 3801 | case SPECPDL_UNWIND_VOID: |
| 3788 | case SPECPDL_BACKTRACE: | 3802 | case SPECPDL_BACKTRACE: |
| 3789 | break; | 3803 | break; |
| @@ -3917,6 +3931,7 @@ NFRAMES and BASE specify the activation frame to use, as in `backtrace-frame'. | |||
| 3917 | case SPECPDL_UNWIND_ARRAY: | 3931 | case SPECPDL_UNWIND_ARRAY: |
| 3918 | case SPECPDL_UNWIND_PTR: | 3932 | case SPECPDL_UNWIND_PTR: |
| 3919 | case SPECPDL_UNWIND_INT: | 3933 | case SPECPDL_UNWIND_INT: |
| 3934 | case SPECPDL_UNWIND_INTMAX: | ||
| 3920 | case SPECPDL_UNWIND_EXCURSION: | 3935 | case SPECPDL_UNWIND_EXCURSION: |
| 3921 | case SPECPDL_UNWIND_VOID: | 3936 | case SPECPDL_UNWIND_VOID: |
| 3922 | case SPECPDL_BACKTRACE: | 3937 | case SPECPDL_BACKTRACE: |
| @@ -3979,6 +3994,7 @@ mark_specpdl (union specbinding *first, union specbinding *ptr) | |||
| 3979 | 3994 | ||
| 3980 | case SPECPDL_UNWIND_PTR: | 3995 | case SPECPDL_UNWIND_PTR: |
| 3981 | case SPECPDL_UNWIND_INT: | 3996 | case SPECPDL_UNWIND_INT: |
| 3997 | case SPECPDL_UNWIND_INTMAX: | ||
| 3982 | case SPECPDL_UNWIND_VOID: | 3998 | case SPECPDL_UNWIND_VOID: |
| 3983 | break; | 3999 | break; |
| 3984 | 4000 | ||
diff --git a/src/lisp.h b/src/lisp.h index 6d101fed908..9d37629bc46 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -3156,6 +3156,7 @@ enum specbind_tag { | |||
| 3156 | Its elements are potential Lisp_Objects. */ | 3156 | Its elements are potential Lisp_Objects. */ |
| 3157 | SPECPDL_UNWIND_PTR, /* Likewise, on void *. */ | 3157 | SPECPDL_UNWIND_PTR, /* Likewise, on void *. */ |
| 3158 | SPECPDL_UNWIND_INT, /* Likewise, on int. */ | 3158 | SPECPDL_UNWIND_INT, /* Likewise, on int. */ |
| 3159 | SPECPDL_UNWIND_INTMAX, /* Likewise, on intmax_t. */ | ||
| 3159 | SPECPDL_UNWIND_EXCURSION, /* Likewise, on an execursion. */ | 3160 | SPECPDL_UNWIND_EXCURSION, /* Likewise, on an execursion. */ |
| 3160 | SPECPDL_UNWIND_VOID, /* Likewise, with no arg. */ | 3161 | SPECPDL_UNWIND_VOID, /* Likewise, with no arg. */ |
| 3161 | SPECPDL_BACKTRACE, /* An element of the backtrace. */ | 3162 | SPECPDL_BACKTRACE, /* An element of the backtrace. */ |
| @@ -3193,6 +3194,11 @@ union specbinding | |||
| 3193 | } unwind_int; | 3194 | } unwind_int; |
| 3194 | struct { | 3195 | struct { |
| 3195 | ENUM_BF (specbind_tag) kind : CHAR_BIT; | 3196 | ENUM_BF (specbind_tag) kind : CHAR_BIT; |
| 3197 | void (*func) (intmax_t); | ||
| 3198 | intmax_t arg; | ||
| 3199 | } unwind_intmax; | ||
| 3200 | struct { | ||
| 3201 | ENUM_BF (specbind_tag) kind : CHAR_BIT; | ||
| 3196 | Lisp_Object marker, window; | 3202 | Lisp_Object marker, window; |
| 3197 | } unwind_excursion; | 3203 | } unwind_excursion; |
| 3198 | struct { | 3204 | struct { |
| @@ -4118,6 +4124,7 @@ extern void record_unwind_protect (void (*) (Lisp_Object), Lisp_Object); | |||
| 4118 | extern void record_unwind_protect_array (Lisp_Object *, ptrdiff_t); | 4124 | extern void record_unwind_protect_array (Lisp_Object *, ptrdiff_t); |
| 4119 | extern void record_unwind_protect_ptr (void (*) (void *), void *); | 4125 | extern void record_unwind_protect_ptr (void (*) (void *), void *); |
| 4120 | extern void record_unwind_protect_int (void (*) (int), int); | 4126 | extern void record_unwind_protect_int (void (*) (int), int); |
| 4127 | extern void record_unwind_protect_intmax (void (*) (intmax_t), intmax_t); | ||
| 4121 | extern void record_unwind_protect_void (void (*) (void)); | 4128 | extern void record_unwind_protect_void (void (*) (void)); |
| 4122 | extern void record_unwind_protect_excursion (void); | 4129 | extern void record_unwind_protect_excursion (void); |
| 4123 | extern void record_unwind_protect_nothing (void); | 4130 | extern void record_unwind_protect_nothing (void); |