-
Notifications
You must be signed in to change notification settings - Fork 1.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
Marking an FFI function as leaf call blocks other Isolates #53030
Comments
Could you provide a full repro? I would suspect that this is a duplicate of #51254 and #51261 - though leaf vs non-leaf should not matter in this particular case AFAIK. Note that you should not mark potentially blocking functions as leaf (we should probably update documentation to mention that @dcharkes). VM can't do GCs while one of the threads are in the leaf call - so any attempt to trigger GC would block until blocking function returns. |
It seems to be a separate issue from the 16 isolate maximum. It even happens with two isolates. I'll create a full example. If leaf calls are not allowed to block the docs definitely need to be updated. They just say
|
Thanks. FWIW I don't think it should dead lock with something like We will update the documentation - in general you are supposed to make leaf only those functions which are very small and short running where the overhead of full blown transition (with safepoint state updates) is too high compared to the overhead of the function itself. Don't mark anything else as leaf. |
Oh yes you are right that is exactly what happens. I tried it again. |
Under certain conditions calling a leaf function can
deadlock the appblock other Isolates even though it does not call back into the Dart VM. Changing it to a non-leaf call works as expected.Steps to reproduce:
sleep()
for exampleI tested this on macOS M1 but it does not seem to be platform dependent.
The text was updated successfully, but these errors were encountered: