aboutsummaryrefslogtreecommitdiffstats
path: root/src/thread.c
diff options
context:
space:
mode:
authorPaul Eggert2020-05-25 20:26:14 -0700
committerPaul Eggert2020-05-25 20:29:50 -0700
commit0dc529175dc027c1567fb9b7cd529d29236aad44 (patch)
tree12e250b10b6a14d25c3c6dacc8ee82bd9e8fc4e2 /src/thread.c
parent8b940dac32c2a37f93b8670751a0e5f72ec86cea (diff)
downloademacs-0dc529175dc027c1567fb9b7cd529d29236aad44.tar.gz
emacs-0dc529175dc027c1567fb9b7cd529d29236aad44.zip
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/thread.c')
-rw-r--r--src/thread.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/thread.c b/src/thread.c
index df1a7053826..b638dd77f8b 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -717,12 +717,17 @@ run_thread (void *state)
717{ 717{
718 /* Make sure stack_top and m_stack_bottom are properly aligned as GC 718 /* Make sure stack_top and m_stack_bottom are properly aligned as GC
719 expects. */ 719 expects. */
720 max_align_t stack_pos; 720 union
721 {
722 Lisp_Object o;
723 void *p;
724 char c;
725 } stack_pos;
721 726
722 struct thread_state *self = state; 727 struct thread_state *self = state;
723 struct thread_state **iter; 728 struct thread_state **iter;
724 729
725 self->m_stack_bottom = self->stack_top = (char *) &stack_pos; 730 self->m_stack_bottom = self->stack_top = &stack_pos.c;
726 self->thread_id = sys_thread_self (); 731 self->thread_id = sys_thread_self ();
727 732
728 if (self->thread_name) 733 if (self->thread_name)