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 committed by Andreas Schwab
parent 758e9a8ed4
commit fdd1b3e020
4 changed files with 13 additions and 0 deletions

View file

@ -6003,6 +6003,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

@ -3975,6 +3975,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

@ -347,4 +347,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