Skip to content

Introduce vm annotation, use it on Future, Zone classes to prevent instances of those from being sent #51722

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

Closed
aam opened this issue Mar 13, 2023 · 2 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-async

Comments

@aam
Copy link
Contributor

aam commented Mar 13, 2023

Sending some classes instances(Future, Zone, etc) across isolates can succeed or fail in hard to reason about fashion. It seems appropriate to restrict those from being sent across altogether.

As proposed on #51594 (comment) we should introduce vm annotation that would make it possible to prohibit those from being sent.

cc @mkustermann @lrhn

@aam aam added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-async labels Mar 13, 2023
@aam aam self-assigned this Mar 13, 2023
@lrhn
Copy link
Member

lrhn commented Mar 13, 2023

I suggest @pragma("vm:isolate-unsendable").

We can always create an internal const unsendable = pragma("vm:isolate-unsendable"); if we want it to look prettier, but using this object as annotation, the same annotation can also be applied outside of the platform libraries, without us having to expose it directly.

It's an annotation which is isolate-specific, so if it was expose, it should be in dart:isolate.
But we, and probably others, want to use it in libraries that are used when isolates are not available, so we can't depend on dart:isolate for it.

copybara-service bot pushed a commit that referenced this issue Mar 27, 2023
Decorate Zone, Future, Completer, Timer and Stream with newly-introduced pragma to make sure that message verification stops earlier, produces shorter retaining path for the user.

BUG=#51722
TEST=send_unsupported_objects_test,isolate_exit_unsendable_test.dart
CoreLibraryReviewExempt: vm-specific pragmas
Change-Id: I499eea542d228ac9cf0797a682664f93f360dc80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289027
Commit-Queue: Alexander Aprelev <[email protected]>
Reviewed-by: Martin Kustermann <[email protected]>
@mkustermann
Copy link
Member

This has been implemented now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-async
Projects
None yet
Development

No branches or pull requests

3 participants