-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Shut down and restart the Dart VM as needed. #6387
Conversation
Cannot land this ATM as https://dart-review.googlesource.com/c/sdk/+/76561 has not been rolled in. The DartVM tests will crash with this patch applied but the dart-roll not completed. |
runtime/dart_vm.cc
Outdated
return gVM; | ||
|
||
// TODO(chinmaygarde): Make this an assertion instead so that callers are | ||
// notified that the new settings might not hold becuase an exiting VM was |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: because
runtime/dart_vm.cc
Outdated
return gVM; | ||
|
||
// TODO(chinmaygarde): Make this an assertion instead so that callers are | ||
// notified that the new settings might not hold because an exiting VM was |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: existing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
The patch in dart-lang/sdk seems to have been reverted. Stashing this for now till the issues are resolved. |
4c43db7
to
6d4b65b
Compare
More issues have been found in the VM while attempting a restart (described here). |
2add29d
to
3f9387a
Compare
3f9387a
to
89c8fdd
Compare
I am still unable to set flags at the ToT Dart VM. |
72bb0ba
to
a9d48df
Compare
541364d
to
4f185c5
Compare
@a-siva Any update on the Dart team trying to land this? |
This is fixed in the bleeding edge Dart sources and if we can get a roll of Dart into flutter we should be able to verify the fixes. |
A couple of rolls have landed. Retrying. |
4f185c5
to
fb5c35a
Compare
@a-siva There still seems to be a race when the VM is shutdown immediately after launch. Running the Error:
Backtrace:
|
Will take a look. |
@a-siva Thanks! I have rebased the branch to ToT and pushed the update. You should just be able to pull and run the unit-test target. |
With this PR it appears that Dart_Cleanup gets called from within the isolate create callback function when the service isolate is being created. We do not expect Dart_Cleanup to be called from within the create callback (there should have been a check and error message for this). |
Thanks! I did not notice this was in the create callback since that was on another thread. This means there is a legitimate race condition. I'll work on fixing isolate VM lifecycle to avoid this issue. |
The shell was already designed to cleanly shut down the VM but it couldnt earlier as Dart_Initialize could never be called after a Dart_Cleanup. This meant that shutting down an engine instance could not shut down the VM to save memory because newly created engines in the process after that point couldn't restart the VM. There can only be one VM running in a process at a time.
fb5c35a
to
5d38170
Compare
I am reworking DartVM lifecycle in a major way after talking to @a-siva. Will open another PR when done. |
The new version of this PR is #7832. Disregarding the LGTM here since that version is substantially different from this one. |
The shell was already designed to cleanly shut down the VM but it couldn't
earlier as
Dart_Initialize
could never be called again after aDart_Cleanup
. Thismeant that shutting down an engine instance could not shut down the VM to save
memory because newly created engines in the process after that point couldn't
restart the VM. There can only be one VM running in a process at a time.
This limitation was lifted in https://dart-review.googlesource.com/c/sdk/+/76561.