From: ko1@...
Date: 2018-08-08T05:53:05+00:00
Subject: [ruby-core:88341] [Ruby trunk Bug#14945] [PATCH] thread.c (blocking_region_end): clear ubf before unregister_ubf_list

Issue #14945 has been updated by ko1 (Koichi Sasada).


ko1 (Koichi Sasada) wrote:
> One off topic question. `list_empty()` is thread-safe?

Sorry it should be safe (I misread as other operation. sorry).


----------------------------------------
Bug #14945: [PATCH] thread.c (blocking_region_end): clear ubf before unregister_ubf_list
https://bugs.ruby-lang.org/issues/14945#change-73369

* Author: normalperson (Eric Wong)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.3: REQUIRED, 2.4: REQUIRED, 2.5: REQUIRED
----------------------------------------
thread.c (blocking_region_end): clear ubf before unregister_ubf_list

If we keep ubf set after unregistering, there is a window for
other threads (including timer thread) to put this thread back
on the ubf_list right away.  Entering ubf_list unexpectedly
after GVL acquisition may cause spurious wakeup and trigger
unexpected behavior.

Finally, clear ubf before acquiring GVL, to since ubf is useless
during GVL acquisition anyways and we don't want to waste cycles
in other threads calling ubf for useless work.



I found this bug while rewriting GVL to handle timer-thread duty
and eliminate separate timer thread.


---Files--------------------------------
0001-thread.c-blocking_region_end-clear-ubf-before-unregi.patch (1.56 KB)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>