Skip to content

Commit fdd1b3e

Browse files
Eli-Zaretskiiandreas-schwab
authored andcommitted
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.
1 parent 758e9a8 commit fdd1b3e

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

src/alloc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6003,6 +6003,8 @@ garbage_collect_1 (void *end)
60036003
VECTOR_UNMARK (&buffer_defaults);
60046004
VECTOR_UNMARK (&buffer_local_symbols);
60056005

6006+
unmark_main_thread ();
6007+
60066008
check_cons_list ();
60076009

60086010
gc_in_progress = 0;

src/lisp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3975,6 +3975,7 @@ extern void syms_of_module (void);
39753975

39763976
/* Defined in thread.c. */
39773977
extern void mark_threads (void);
3978+
extern void unmark_main_thread (void);
39783979

39793980
/* Defined in editfns.c. */
39803981
extern void insert1 (Lisp_Object);

src/thread.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,12 @@ mark_threads (void)
656656
flush_stack_call_func (mark_threads_callback, NULL);
657657
}
658658

659+
void
660+
unmark_main_thread (void)
661+
{
662+
main_thread.header.size &= ~ARRAY_MARK_FLAG;
663+
}
664+
659665

660666

661667
static void

test/src/thread-tests.el

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,4 +347,8 @@
347347
(should (= (length (all-threads)) 1))
348348
(should (equal (thread-last-error) '(error "Die, die, die!")))))
349349

350+
(ert-deftest threads-test-bug33073 ()
351+
(let ((th (make-thread 'ignore)))
352+
(should-not (equal th main-thread))))
353+
350354
;;; threads.el ends here

0 commit comments

Comments
 (0)