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

Fix #26 - Avoid notifying unassigned SharedArrayBuffer entry #27

Merged
merged 2 commits into from
Oct 10, 2023

Conversation

WebReflection
Copy link
Owner

This MR avoids a very subtle bug that is hard to repeat consistently but that, to my understanding, boils down to this issue:

  • if the shared array buffer is not changed but notified as "nothing to return" without an explicit value set to its index [0] then Atomics.wait(sb, 0, 0, delay) might fail unexpectedly without any warning whatsoever
  • if the shared array buffer has an explicit value set at index [0] then everything always works as expected
  • if the remote function returns a value, hence it assign some length to the [0] it always works too

I have no idea if it's worth it to me to file a bug to all vendors as I think this is an intended behavior.

Changes

  • be sure that if the remote call does not return anything (undefined) a value at index [0] is set as -1 so that negative result length means no further actions need to be performed
  • when the length is indeed less than zero, early return without asking for data to unserialize

@WebReflection WebReflection merged commit 7891cd9 into main Oct 10, 2023
2 checks passed
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.

1 participant