-
Notifications
You must be signed in to change notification settings - Fork 315
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
Unsoundness when starting an isolate per thread #1467
Comments
Do you mind providing the output of the data races? v8 may have some undocumented ordering requirements that we may need to encode via mutexes. I assume these don't happen when you serialize them on different threads via mutex? |
What do you mean by this? Serialize what? Lock what? The output of TSan:
I got even more data races in my real code, when I actually used the isolates. This lead to a segfault. |
Serialization and locking refer to mutual exclusion, ie: We can certainly fix this or accept a PR, but we would need to understand if this means:
|
Oh serializing as in running serially, I thought you meant serializing as in marshalling :P Indeed it seems like only the first isolate must be started on its own |
This is also a good moment to revise the API. I'll expand on another issue though |
I'll work on this |
This is correct, |
I checked the PR #1411, seems there is some hard issue in the design of the |
What you can do in this case is instead of putting it in a task, you just put it in a plain old thread, and then communicate back and forth with channels. It's wouldn't be a good idea to put them in a task in the first place since they would be blocking most of the time (well, depending on your workload). |
For everyone else finding this unsoundness bug here's a work around, you just need to use a OnceLock: |
Thanks for sharing! One more question: do you have any idea, does V8 natively support async/await keyword? or the runtime need to implement it? and how to implement? Update: I searched async/await in ECMAScript https://ecma-international.org/publications-and-standards/standards/ecma-262/, seems it's already been mentioned several times. I guess it's already natively supported. But still wonder how does it work when rusty_v8 running in a single thread. Does the V8 Context switches between different async functions inside a single thread? |
Please open a new issue or discussion for new topics 😅 |
Is it supposed to be sound to instantiate one isolate per thread?
If it's not the API shouldn't allow it.
If it is, you have data races as reported by ThreadSanitizer at least when creating and dropping the isolates.
There are more data races reported by it.
This code can be ran with
RUSTFLAGS=-Zsanitizer=thread cargo +nightly run -r -Zbuild-std --target x86_64-unknown-linux-gnu
The text was updated successfully, but these errors were encountered: