-
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
[vm/ffi] Calling NativeCallable.listener
from a NativeFinalizer
callback
#54939
Comments
The real issue with this use case is a GC deadlock. I've investigated this before, as part of the ObjC Block finalizer flow: At that time I decided it wasn't worth the effort to support this case, because I could just clean up the blocks using native code. Do we have a more compelling use case now? |
The use case is native finalizers which have an out parameter to communicate error messages: So the issue here is that we need to run the argument unwrapping in a Dart isolate before it queues the message on the event loop. The marshalling can also no be done in a new isolate group (with separate gc), because it could potentially instantiate Some ideas:
Maybe @mkustermann has some bright ideas on how we could enable using |
As discussed offline with @liamappelbe and @mkustermann:
|
The C API for android logging (similar to |
Currently, calling a
NativeCallable.listener
from aNativeFinalizer
callback hits an assert:sdk/runtime/vm/runtime_entry.cc
Lines 4037 to 4043 in 1e0223e
The assumption is that if we have a current thread, it must be in native code. However, when the
NativeCallable.listener
is called from a finalizer callback, we have a current thread, but it is in the VM.Repro: https://github.com/dart-lang/native/tree/native-finalizer/pkgs/native_assets_cli/example/native_add_library
@liamappelbe Could you please take a look at supporting this use case?
cc @mkustermann
The text was updated successfully, but these errors were encountered: