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 default variables concurrency issues #6996

Conversation

APickledWalrus
Copy link
Member

Description

This PR fixes to aim rare concurrency issues that can occur with default variables. Specifically, this may occur when two (or more) parts of a script operating on different threads (e.g. a script has an async event) try to work with default variables at the same time. What occurs is that not all push calls are successful (e.g. one overrides another), leading to the pop calls causing NoSuchElementExceptions.

I have chosen to use synchronization blocks over implementations such as ConcurrentLinkedQueue. I found performance of the synchronization blocks to be better, and this is not a common occurrence that would lead to threads waiting for access.


Target Minecraft Versions: any
Requirements: none
Related Issues: Reported through Discord

@APickledWalrus APickledWalrus added bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. 2.9 Targeting a 2.9.X version release labels Aug 22, 2024
Copy link
Member

@Pikachu920 Pikachu920 left a comment

Choose a reason for hiding this comment

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

can we add a regression test?

@APickledWalrus
Copy link
Member Author

can we add a regression test?

Hmm I'm not sure how easy it will be to make happen. I can see what I can do with JUnit though

@Moderocky Moderocky merged commit 37449b1 into SkriptLang:dev/patch Aug 31, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.9 Targeting a 2.9.X version release bug An issue that needs to be fixed. Alternatively, a PR fixing an issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants