Repository navigation
Keep masked sleep going and don't lose a raise followed by kill - #10064
Merged
Merged
Conversation
executeTask checked for interrupts again in its finally block, even when the task was already throwing a raised interrupt. If Thread#raise was followed by Thread#kill, the second check threw the kill and the raised exception was lost. This happened in Queue#pop, with and without a timeout. Check again only when the task returned or was interrupted by Java, as MRI checks interrupts after a blocking region only on normal return.
Thread#raise and Thread#kill wake a sleeping thread even when handle_interrupt masks them. Kernel#sleep then returned early, so a masked sleep 1 could end after 0.3 seconds. Like MRI's sleep_hrtime and sleep_forever, run any interrupt that is not masked and go back to sleep. Only the deadline or Thread#wakeup ends the sleep. Part of jruby#10028.
kares
reviewed
Nov 17, 2026
| * @param context the current context | ||
| * @param nanoseconds time to sleep. Zero sleeps until woken. | ||
| */ | ||
| public void sleepUntilWakeup(ThreadContext context, long nanoseconds) throws InterruptedException { |
Member
There was a problem hiding this comment.
nit-pick: not sure whether to expose this on a core clas - usually it's best to hide and be mindful whether we want things as public API, in this case:
Suggested change
| public void sleepUntilWakeup(ThreadContext context, long nanoseconds) throws InterruptedException { | |
| void sleepUntilWakeup(ThreadContext context, long nanoseconds) throws InterruptedException { |
Member
There was a problem hiding this comment.
Agreed. Don't expose until it's obviously needed as a public API.
headius
approved these changes
Nov 17, 2026
| * @param context the current context | ||
| * @param nanoseconds time to sleep. Zero sleeps until woken. | ||
| */ | ||
| public void sleepUntilWakeup(ThreadContext context, long nanoseconds) throws InterruptedException { |
Member
There was a problem hiding this comment.
Agreed. Don't expose until it's obviously needed as a public API.
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.
Fixes #10028 (the rest of it).
Thread#raiseorThread#killendedKernel#sleepearly. Now sleep keeps going until its time is up orThread#wakeupis called, like MRI'ssleep_hrtimeandsleep_forever.t.raise "boom"; t.kill, a thread blocked inQueue#poporsleepdied from the kill and the raise was lost.executeTaskno longer checks for interrupts a second time when one was already raised, like MRI'srb_nogvl.