-
Notifications
You must be signed in to change notification settings - Fork 942
Race Condition in WASM Code #497
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
Comments
Hi @indolering, thanks for pointing this out. The current code using the low-level wasm However, the older code that calls directly |
I'm not entirely sure what that code is doing, but @sunfishcode is one of WASM/WASI's architects. I'm inclined to believe them when they say that there is a race condition. But they are very busy, perhaps @jedisct1 could chime in? If you don't have the resources to fix it, I agree that it would be better to leave this functionality in but it should be documented in the code. |
The |
Thanks @sunfishcode for helping out. I understand the issue (and similar to issues with
Thanks again |
Yes, that's the proposal; see the resizing section: after a Explicit synchronization between threads would be another option. At a quick scan of the code, it appears mimalloc doesn't use mutexes, and has its own atomics and spinning, so it's not immediately clear to me what to suggest here.
The |
Thanks @sunfishcode for the feedback. Yeah, the current API is quite bad for getting aligned allocation; I now protect with a lock and try opportunistic alignment but things can go bad. (see the code). It would be great to extend the WASM instruction with the ability to allocate aligned memory; I am on the WASM stack committee (working on having first-class continuations/algebraic effects, proposal 1359) but I am not familiar with the design considerations for memory allocation. Especially for wasm64, an |
I'm not a C programmer, but it appears as if this race condition (which was pointed out in a code review a few days after the WASM PR was merged) is still present. A comment states that this chunk of code is no longer used, but the buggy code should be removed or at least documented. I am unable to tell whether the problem was ported over to
sbrk()
.My apologies if this is incorrect or unhelpful, I performed a few searches and a manual review of commits but didn't turn up anything suggesting this had been fixed.
The text was updated successfully, but these errors were encountered: