From 587dd92ea0814eafe4064be69d6d9e0fa8dbac1b Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 27 Aug 2012 10:12:29 -0600 Subject: [PATCH] cannot thread-join the current thread --- src/thread.c | 3 +++ test/automated/threads.el | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/thread.c b/src/thread.c index 01d2fd0d6eb..551f3de10e4 100644 --- a/src/thread.c +++ b/src/thread.c @@ -852,6 +852,9 @@ It is an error for a thread to try to join itself. */) CHECK_THREAD (thread); tstate = XTHREAD (thread); + if (tstate == current_thread) + error ("cannot join current thread"); + if (tstate->m_specpdl != NULL) flush_stack_call_func (thread_join_callback, tstate); diff --git a/test/automated/threads.el b/test/automated/threads.el index b1c2af59600..db6aa41d63a 100644 --- a/test/automated/threads.el +++ b/test/automated/threads.el @@ -70,6 +70,10 @@ (and threads-test-global (not (thread-alive-p thread))))))) +(ert-deftest threads-join-self () + "cannot thread-join the current thread" + (should-error (thread-join (current-thread)))) + (defvar threads-test-binding nil) (defun threads-test-thread2 () -- 2.39.5