Repository navigation
Conversation
…signal at a timeout, MRI's timeout errors The wait_spec failures in Util/sweep-core.tsv were stale (fixed by 4c5d542 and 4b0848c): spec/core/conditionvariable passes, 11 of 11. Comparing against MRI 4.0 turned up three problems the specs do not cover: - #wait on a mutex the thread does not hold raised ThreadError but left the thread queued as a waiter. The next #signal went to it: the real waiter slept through its timeout, and the failed caller kept a latched wake that cut its next sleep short. - #signal woke a waiter outside the waiter-list lock, so one whose timeout ran out at the same moment answered nil, the signal was lost, and the wake stayed latched. The wake is now sent under the lock, and a waiter that finds itself taken off the list counts as signalled and clears the latch. - #wait(mutex, timeout) took Queue#pop's conversion: a negative timeout returned at once and other types got "no implicit conversion". It now shares Mutex#sleep's conversion, which also learns MRI's RangeError for a Bignum, NaN and Infinity. Util/condvar-matrix.rb diffs these against CRuby. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…or a long as their timeout MRI turns a timeout that is not an Integer or a Float into an interval through divmod(1): the whole seconds through #to_int, the fraction times 1_000_000_000 as nanoseconds; an object without a #divmod that answers an Array is "can't convert X into time interval". IronRuby only took an int or a double, so a Rational or a BigDecimal was a TypeError - and so was any Integer past 32 bits, which IronRuby holds as a long (m.sleep(2**40) raised instead of sleeping). A Bignum is MRI's RangeError only when it does not fit a long. Initializers.Generated.cs regenerated with ClassInitGenerator: the two signatures only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Largo
force-pushed
the
fix/condvar-wait
branch
from
October 29, 2026 14:35
f168eae to
e737d59
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #4. It builds on the shared
RubyMutex.ToSleepSecondsconversion added there.MRI converts a timeout that isn't an Integer or a Float through
divmod(1). The whole seconds go throughto_int, and the fraction is multiplied by 1_000_000_000 to give nanoseconds. Anything without a#divmodthat returns an Array raises "can't convert X into time interval". IronRuby accepted only an int or a double, so these raised TypeError:m.sleep(Rational(1, 100))andcv.wait(m, BigDecimal("0.01")), which work in MRI.m.sleep(2**40), which MRI sleeps on. IronRuby stores an Integer past 32 bits as a CLRlong, and the conversion didn't handle that type.A Bignum now raises MRI's RangeError only when it doesn't fit a long.
Initializers.Generated.cswas regenerated with ClassInitGenerator, and the regenerated file differs only in the two changed signatures (8 lines).Testing (Linux, net10.0)
Util/condvar-matrix.rbgains Rational, BigDecimal, custom#divmod, Complex, Object and2**40cases, and its output still matches CRuby.Thread#killfiber flake that predates this branch (see ConditionVariable#wait: no stale waiter after a failed wait, no lost signal at a timeout, MRI's timeout errors #4).Still different from MRI (not in this PR)
[nil, 0]from#divmodreports IronRuby's generic "no implicit conversion of nil into Integer" (MRI: "from nil to integer"). NoMethodError messages use IronRuby's backtick quoting.divmod→[0, -0.05]) raises ArgumentError here. MRI blocks forever.🤖 Generated with Claude Code