Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make signal handler setup synchronous to avoid race conditions #4256

Closed
wants to merge 1 commit into from

Conversation

niner
Copy link
Collaborator

@niner niner commented Mar 20, 2021

On MoarVM setup of a signal handler is itself an asynchronous operation. Wait
for it to complete before returning as not only our spec tests but probably
every single user expects the signal handler to be in place at that point. This
was already true for the JVM and JS backends.

Fixes a race condition in t/spec/S17-procasync/kill.t

@MasterDuke17
Copy link
Contributor

Relies on MoarVM/MoarVM#1445

@niner niner force-pushed the signal_handler_setup_notification branch from 72f105c to fddb9d3 Compare March 21, 2021 15:04
@niner
Copy link
Collaborator Author

niner commented Mar 21, 2021

I updated the commit to use a Semaphore instead of the Promise and await. With this, signal handler setup will behave synchronously even when done as part of react/whenever setup, making Raku/roast@099d13e obsolete.

my $cancellation := nqp::signal($!scheduler.queue(:hint-time-sensitive),
my $queue := $!scheduler.queue(:hint-time-sensitive);
#?if moar
my $setup-semaphore = Semaphore.new(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:= perhaps? Saves one Scalar and indicates immutability?

@niner niner force-pushed the signal_handler_setup_notification branch from fddb9d3 to 745466a Compare March 21, 2021 20:38
@niner
Copy link
Collaborator Author

niner commented Mar 21, 2021 via email

On MoarVM setup of a signal handler is itself an asynchronous operation. Wait
for it to complete before returning as not only our spec tests but probably
every single user expects the signal handler to be in place at that point. This
was already true for the JVM and JS backends.

Fixes a race condition in t/spec/S17-procasync/kill.t
@niner niner force-pushed the signal_handler_setup_notification branch from 745466a to 26a767c Compare March 21, 2021 20:50
@niner
Copy link
Collaborator Author

niner commented Mar 27, 2021

Rebased and merged manually (to get the NQP bump in)

@niner niner closed this Mar 27, 2021
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.

None yet

3 participants