diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2020-05-25 20:26:14 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2020-05-25 20:29:50 -0700 |
commit | 0dc529175dc027c1567fb9b7cd529d29236aad44 (patch) | |
tree | 12e250b10b6a14d25c3c6dacc8ee82bd9e8fc4e2 /src/lisp.h | |
parent | 8b940dac32c2a37f93b8670751a0e5f72ec86cea (diff) | |
download | emacs-0dc529175dc027c1567fb9b7cd529d29236aad44.tar.gz |
Fix aborts due to GC losing pseudovectors
Problem reported by Eli Zaretskii (Bug#41321).
* src/alloc.c (MALLOC_ALIGNMENT_BOUND): New constant.
(LISP_ALIGNMENT): Lower it to avoid crashes on MinGW and similarly
buggy platforms where malloc returns pointers not aligned to
alignof (max_align_t). But keep it higher on platforms where this
is known to work, as it helps GC performance.
(MALLOC_IS_LISP_ALIGNED): Define in terms of the other two.
* src/alloc.c (stacktop_sentry):
* src/thread.c (run_thread):
Don’t overalign or oversize stack sentries; they need to be
aligned only for pointers and Lisp_Object, not for arbitrary
pseudovector contents.
* src/lisp.h (union emacs_align_type): New type, used for
LISP_ALIGNMENT.
Diffstat (limited to 'src/lisp.h')
-rw-r--r-- | src/lisp.h | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/src/lisp.h b/src/lisp.h index 85bdc172b20..937052f6df8 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -277,7 +277,8 @@ error !; allocation in a containing union that has GCALIGNED_UNION_MEMBER) and does not contain a GC-aligned struct or union, putting GCALIGNED_STRUCT after its closing '}' can help the compiler - generate better code. + generate better code. Also, such structs should be added to the + emacs_align_type union. Although these macros are reasonably portable, they are not guaranteed on non-GCC platforms, as C11 does not require support @@ -5059,6 +5060,46 @@ maybe_gc (void) maybe_garbage_collect (); } +/* A type with alignment at least as large as any object that Emacs + allocates. This is not max_align_t because some platforms (e.g., + mingw) have buggy malloc implementations that do not align for + max_align_t. This union contains types of all GCALIGNED_STRUCT + components visible here. */ +union emacs_align_type +{ + struct Lisp_Bool_Vector Lisp_Bool_Vector; + struct Lisp_Char_Table Lisp_Char_Table; + struct Lisp_CondVar Lisp_CondVar; + struct Lisp_Finalizer Lisp_Finalizer; + struct Lisp_Float Lisp_Float; + struct Lisp_Hash_Table Lisp_Hash_Table; + struct Lisp_Marker Lisp_Marker; + struct Lisp_Misc_Ptr Lisp_Misc_Ptr; + struct Lisp_Mutex Lisp_Mutex; + struct Lisp_Overlay Lisp_Overlay; + struct Lisp_Sub_Char_Table Lisp_Sub_Char_Table; + struct Lisp_Subr Lisp_Subr; + struct Lisp_User_Ptr Lisp_User_Ptr; + struct Lisp_Vector Lisp_Vector; + struct thread_state thread_state; + + /* Omit the following since they would require including bignum.h, + frame.h etc., and in practice their alignments never exceed that + of the structs already listed. */ +#if 0 + struct frame frame; + struct Lisp_Bignum Lisp_Bignum; + struct Lisp_Module_Function Lisp_Module_Function; + struct Lisp_Process Lisp_Process; + struct save_window_data save_window_data; + struct scroll_bar scroll_bar; + struct terminal terminal; + struct window window; + struct xwidget xwidget; + struct xwidget_view xwidget_view; +#endif +}; + INLINE_HEADER_END #endif /* EMACS_LISP_H */ |