aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorEli Zaretskii2016-12-12 19:08:21 +0200
committerEli Zaretskii2016-12-12 19:08:21 +0200
commit825f4dd42f0f656bcb4536546b33fe8e54756468 (patch)
tree267e32c802f96d0a2e32b82f35fbb924b6656dd5 /test/src
parenta416e1d6c111527205f3583c8d201bf95af6fa20 (diff)
downloademacs-825f4dd42f0f656bcb4536546b33fe8e54756468.tar.gz
emacs-825f4dd42f0f656bcb4536546b33fe8e54756468.zip
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/src')
-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 @@
235 (sit-for 1) 235 (sit-for 1)
236 (should (= (point) 21)))) 236 (should (= (point) 21))))
237 237
238(ert-deftest thread-signal-early ()
239 "Test signaling a thread as soon as it is started by the OS."
240 (let ((thread
241 (make-thread #'(lambda ()
242 (while t (thread-yield))))))
243 (thread-signal thread 'error nil)
244 (sit-for 1)
245 (should-not (thread-alive-p thread))))
246
238;;; threads.el ends here 247;;; threads.el ends here