Avoid assertion violation when comparing with main-thread

* src/thread.c (unmark_main_thread): New function.
* src/lisp.h (unmark_main_thread): Prototype it.
* src/alloc.c (garbage_collect_1): Call it after sweeping.
(Bug#33073)

* test/src/thread-tests.el (threads-test-bug33073): New test.
This commit is contained in:
Eli Zaretskii 2018-10-17 18:19:47 +03:00
parent 134ba45bf0
commit 7356743232
4 changed files with 13 additions and 0 deletions

View file

@ -5863,6 +5863,8 @@ garbage_collect_1 (void *end)
VECTOR_UNMARK (&buffer_defaults);
VECTOR_UNMARK (&buffer_local_symbols);
unmark_main_thread ();
check_cons_list ();
gc_in_progress = 0;

View file

@ -4011,6 +4011,7 @@ extern void syms_of_module (void);
/* Defined in thread.c. */
extern void mark_threads (void);
extern void unmark_main_thread (void);
/* Defined in editfns.c. */
extern void insert1 (Lisp_Object);

View file

@ -656,6 +656,12 @@ mark_threads (void)
flush_stack_call_func (mark_threads_callback, NULL);
}
void
unmark_main_thread (void)
{
main_thread.header.size &= ~ARRAY_MARK_FLAG;
}
static void

View file

@ -388,4 +388,8 @@
(should (= (length (all-threads)) 1))
(should (equal (thread-last-error) '(error "Die, die, die!")))))
(ert-deftest threads-test-bug33073 ()
(let ((th (make-thread 'ignore)))
(should-not (equal th main-thread))))
;;; threads.el ends here