[#47409] [ruby-trunk - Feature #6973][Open] Add an #integral? method to Numeric to test for whole-number values — "regularfry (Alex Young)" <alex@...>

12 messages 2012/09/03

[#47481] [ruby-trunk - Bug #7008][Open] rake is crashing when trying to compile ffi gem — "drookie (Eugene M. Zheganin Eugene M. Zheganin)" <eugene@...>

10 messages 2012/09/12

[#47505] [ruby-trunk - Feature #7019][Open] allow `private` and `protected` keywords to take blocks — "alexeymuranov (Alexey Muranov)" <redmine@...>

15 messages 2012/09/13

[#47582] [ruby-trunk - Bug #7037][Open] float formatting inconsistently rounds half to even — "headius (Charles Nutter)" <headius@...>

14 messages 2012/09/19

[#47638] [ruby-trunk - Bug #7046][Open] ERB#run and ERB#result are not safe for concurrent use — "headius (Charles Nutter)" <headius@...>

11 messages 2012/09/21

[#47655] [ruby-trunk - Feature #7051][Open] Extend caller_locations API to include klass and bindings. Allow caller_locations as a method hanging off Thread. — "sam.saffron (Sam Saffron)" <sam.saffron@...>

13 messages 2012/09/23

[#47657] [ruby-trunk - Feature #7055][Open] Allow `.foo=` as a synonym of `self.foo=` — "alexeymuranov (Alexey Muranov)" <redmine@...>

11 messages 2012/09/23

[#47730] [ruby-trunk - Bug #7085][Open] Subversion → GitHub gateway stops. — "shyouhei (Shyouhei Urabe)" <shyouhei@...>

27 messages 2012/09/29

[#47735] [ruby-trunk - Bug #7087][Open] ::ConditionVariable#wait does not work with Monitor because Monitor#sleep does not exist — "rklemme (Robert Klemme)" <shortcutter@...>

10 messages 2012/09/29

[#47759] [ruby-trunk - Bug #7092][Open] StringScanner start-of-line matches false positives, while lookbehind for a newline gives false negatives — "jayferd (Jay Adkisson)" <jjmadkisson@...>

8 messages 2012/09/30

[ruby-core:47532] [ruby-trunk - Bug #6174] Fix collision of ConditionVariable#wait timeout and #signal (+ other cosmetic changes)

From: "kosaki (Motohiro KOSAKI)" <kosaki.motohiro@...>
Date: 2012-09-14 18:13:37 UTC
List: ruby-core #47532
Issue #6174 has been updated by kosaki (Motohiro KOSAKI).


> I cann't understand, why "main thread shouldn't take a mutex"? In real application it could be very other thread, not main.
> Holding mutex by main thread were intentionally to expose this race. Race could happen without it, but it would be hard to catch.

While the mutex is held by any thread, condvar.wait can't be return. It's one of basic condvar semantics. and sleep(0.01) don't release
mutex at all. Thus, sleep(0.01) of main thread can't help to wakeup and finish sub thread.

----------------------------------------
Bug #6174: Fix collision of ConditionVariable#wait timeout and #signal (+ other cosmetic changes)
https://bugs.ruby-lang.org/issues/6174#change-29311

Author: funny_falcon (Yura Sokolov)
Status: Rejected
Priority: Normal
Assignee: kosaki (Motohiro KOSAKI)
Category: lib
Target version: 2.0.0
ruby -v: ruby 2.0.0dev (2012-03-17 trunk 35075) [i686-linux]


1. Currently, when Thread wakes on timeout, it could not remove itself from ConditionVariable waiters until it acquires lock.
So that, when ConditionVariable#signal is called, it will try to wakeup
such thread, instead of some one else.
https://github.com/funny-falcon/ruby/commit/24a9b6112477b2107ac9a19d0189a11fb97aa891
https://github.com/funny-falcon/ruby/commit/24a9b6112477b2107ac9a19d0189a11fb97aa891.patch

Simple way to avoid it, is to allow Mutex#sleep to recieve a block, which will be called right after Thread will awake, but before Mutex will be tried to lock
https://github.com/funny-falcon/ruby/commit/9e9157c5318926331dbe883416b69d38a58fea5d
https://github.com/funny-falcon/ruby/commit/9e9157c5318926331dbe883416b69d38a58fea5d.patch

2. Since MatzRuby use GVL for thread isolation, and native method could not be interrupted (unless it will), we could remove couple of calles to Mutex#synchronize
https://github.com/funny-falcon/ruby/commit/a9ad8d274b96f14519643fc63327394f72b83516
https://github.com/funny-falcon/ruby/commit/a9ad8d274b96f14519643fc63327394f72b83516.patch

3. Usage of hash with `compare_by_identity` allows remove call to Array#include? in a Queue. Also it allows to remove other call Mutex#synchronize from ConditionVariable#wait in case when we rely on GVL.
https://github.com/funny-falcon/ruby/commit/0da1887a04f7a0e4f9289d2167c2a6d0073651e1
https://github.com/funny-falcon/ruby/commit/0da1887a04f7a0e4f9289d2167c2a6d0073651e1.patch

4. And cosmetic changes to SizedQueue
https://github.com/funny-falcon/ruby/commit/60ed97557c8178bc78edf670f3d53d761e627bf0
https://github.com/funny-falcon/ruby/commit/60ed97557c8178bc78edf670f3d53d761e627bf0.patch

Pull request at once:
https://github.com/ruby/ruby/pull/104
https://github.com/ruby/ruby/pull/104.diff
https://github.com/ruby/ruby/pull/104.patch


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

In This Thread