Skip to content

Fix interrupt bugs wrt bracket masking #171

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

Conversation

natefaubion
Copy link
Collaborator

Currently when we check interrupt status, we are not considering the
bracket masking status. When we enter a masked state (bracketCount > 0),
it should be impossible for an interrupt to terminate evaluation, but
without the bracket check in CATCH, RESUME, and RELEASE, this is
violated.

  • In a nested async generalBracket, the wrong handler is enqueued.
    Since we are in a masked state, it should be impossible for the killed
    branch to be invoked. However, if an interrupt occurs it is currently
    always invoking killed when the branch is actually completed.
  • In a nested bracket, an interrupt will terminate evaluation of the
    inner bracket even though we are in a masked state. This can also happen
    with an inner catch in a masked state.

We need to always consider the masked state (bracketCount > 0) when we
discriminate the interrupt state.

Fixes #170

Currently when we check interrupt status, we are not considering the
bracket masking status. When we enter a masked state (`bracketCount > 0`),
it should be impossible for an interrupt to terminate evaluation, but
without the bracket check in CATCH, RESUME, and RELEASE, this is
violated.

*   In a nested async generalBracket, the wrong handler is enqueued.
Since we are in a masked state, it should be impossible for the `killed`
branch to be invoked. However, if an interrupt occurs it is currently
_always_ invoking `killed` when the branch is actually `completed`.
*   In a nested bracket, an interrupt will terminate evaluation of the
inner bracket even though we are in a masked state. This can also happen
with an inner `catch` in a masked state.

We need to always consider the masked state (`bracketCount > 0`) when we
discriminate the interrupt state.

Fixes purescript-contrib#170
@natefaubion
Copy link
Collaborator Author

/cc @felixSchl

@felixSchl
Copy link

For what it's worth we applied this change to a fairly large codebase without having witnessed any negative side effects so far, and the problem we saw is fixed. We'll be running with these changes from now on and report if anything comes up. Thank you for looking into this and fixing it!

@natefaubion natefaubion merged commit 390857f into purescript-contrib:master Mar 29, 2019
@natefaubion natefaubion deleted the fix-interrupt-bracket-masking branch March 29, 2019 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants