[前][次][番号順一覧][スレッド一覧]

ruby-changes:52241

From: normal <ko1@a...>
Date: Sun, 19 Aug 2018 03:29:37 +0900 (JST)
Subject: [ruby-changes:52241] normal:r64449 (trunk): thread.c (sleep_*): check interrupt before changing th->status

normal	2018-08-19 03:29:28 +0900 (Sun, 19 Aug 2018)

  New Revision: 64449

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64449

  Log:
    thread.c (sleep_*): check interrupt before changing th->status
    
    Having threads switch before we sleep can cause applications
    to misread the state of the thread.  Now, we are consistent
    with blocking_region_begin behavior and change th->status
    AFTER checking interrupts.
    
    Maybe this can fix [Bug #15002]

  Modified files:
    trunk/thread.c
Index: thread.c
===================================================================
--- thread.c	(revision 64448)
+++ thread.c	(revision 64449)
@@ -1186,8 +1186,8 @@ sleep_forever(rb_thread_t *th, unsigned https://github.com/ruby/ruby/blob/trunk/thread.c#L1186
     int woke;
 
     status  = fl & SLEEP_DEADLOCKABLE ? THREAD_STOPPED_FOREVER : THREAD_STOPPED;
-    th->status = status;
     RUBY_VM_CHECK_INTS_BLOCKING(th->ec);
+    th->status = status;
     while (th->status == status) {
 	if (fl & SLEEP_DEADLOCKABLE) {
 	    th->vm->sleeper++;
@@ -1292,8 +1292,8 @@ sleep_timespec(rb_thread_t *th, struct t https://github.com/ruby/ruby/blob/trunk/thread.c#L1292
 
     getclockofday(&end);
     timespec_add(&end, &ts);
-    th->status = THREAD_STOPPED;
     RUBY_VM_CHECK_INTS_BLOCKING(th->ec);
+    th->status = THREAD_STOPPED;
     while (th->status == THREAD_STOPPED) {
 	native_sleep(th, &ts);
 	woke = vm_check_ints_blocking(th->ec);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]