Skip to content

Conversation

@headius
Copy link
Member

@headius headius commented Dec 3, 2024

Avoid polling during propagation and report of a Thread#raise exception. If we dispatch dynamically to the configured stderr, we may hit additional polls that trigger new interrupts, wiping out the raise interrupt currently being handled.

Fixes #8479

@headius headius force-pushed the clear_interrupts_when_interrupting branch from 1e2111e to dab2510 Compare December 3, 2024 15:31
@headius headius force-pushed the clear_interrupts_when_interrupting branch from dab2510 to 92ff9c9 Compare December 3, 2024 15:40
@headius headius force-pushed the clear_interrupts_when_interrupting branch from 92ff9c9 to e77566a Compare December 3, 2024 15:41
@headius
Copy link
Member Author

headius commented Dec 3, 2024

Initial naive attempt clearly doesn't pass.

@headius headius force-pushed the clear_interrupts_when_interrupting branch from e77566a to 663b9d9 Compare December 3, 2024 17:11
@headius headius changed the title Clear interrupt queue when acting on interrupt Avoid re-polling while reporting a Thread#raise Dec 3, 2024
@headius
Copy link
Member Author

headius commented Dec 3, 2024

Replaced original attempt (clear interrupt queue when raising) with a new version that simply avoids polling during IO for the raise report. This should fix the original issue without substantially changing the way interrupts are handled.

@headius headius force-pushed the clear_interrupts_when_interrupting branch 2 times, most recently from 2a07e0f to c8b08d9 Compare December 3, 2024 17:20
Dynamically printing error output to the configured stderr stream
may trigger additional thread interrupt polls, wiping out any
thread interrupt currently being reported or propagated. This
patch avoids such polls by writing directly to the underlying IO
without using Ruby logic if and only if it is the original (boot)
stderr stream.

This also removes a second poll that happens when exiting the
blocking task for a raise, a side effect of using afterBlockingCall
to set the new status. The status update happens again after this
point, and the poll is spurious.

Fixes jruby#8479
@headius headius force-pushed the clear_interrupts_when_interrupting branch from c8b08d9 to 39cd7eb Compare December 3, 2024 17:32
@headius headius marked this pull request as ready for review December 3, 2024 17:40
@headius headius merged commit ab5fc4d into jruby:master Dec 3, 2024
95 checks passed
@headius headius deleted the clear_interrupts_when_interrupting branch December 3, 2024 18:07
@headius headius added this to the JRuby 9.4.10.0 milestone Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Thread interrupt requests can overwrite each other

1 participant