summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2016-12-12 19:08:21 +0200
committerEli Zaretskii <eliz@gnu.org>2016-12-12 19:08:21 +0200
commit825f4dd42f0f656bcb4536546b33fe8e54756468 (patch)
tree267e32c802f96d0a2e32b82f35fbb924b6656dd5 /test
parenta416e1d6c111527205f3583c8d201bf95af6fa20 (diff)
downloademacs-825f4dd42f0f656bcb4536546b33fe8e54756468.tar.gz
Avoid crashing if a new thread is signaled right away
* src/thread.c (post_acquire_global_lock): Don't raise the pending signal if the thread's handlers were not yet set up, as that will cause Emacs to exit with a fatal error. This can happen if a thread is signaled as soon as make-thread returns, before the new thread had an opportunity to acquire the global lock, set up the handlers, and call the thread function. * test/src/thread-tests.el (thread-signal-early): New test.
Diffstat (limited to 'test')
-rw-r--r--test/src/thread-tests.el9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/src/thread-tests.el b/test/src/thread-tests.el
index 7261cda9fbb..26c0b725ff8 100644
--- a/test/src/thread-tests.el
+++ b/test/src/thread-tests.el
@@ -235,4 +235,13 @@
(sit-for 1)
(should (= (point) 21))))
+(ert-deftest thread-signal-early ()
+ "Test signaling a thread as soon as it is started by the OS."
+ (let ((thread
+ (make-thread #'(lambda ()
+ (while t (thread-yield))))))
+ (thread-signal thread 'error nil)
+ (sit-for 1)
+ (should-not (thread-alive-p thread))))
+
;;; threads.el ends here