Skip to content
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

Run Dart finalizer callback for external types when they fail to post #19

Merged
merged 5 commits into from
Apr 14, 2022

Conversation

trueb2
Copy link
Contributor

@trueb2 trueb2 commented Apr 11, 2022

Fix ZeroCopyBuffer memory leak related to discussion in #6.

Even though this memory leak seems unlikely, there should be an attempt to handle failure to post

Fix ZeroCopyBuffer memory leak related to discussion in shekohex#6
@shekohex
Copy link
Owner

Hello @trueb2!
Thank you very much!

Well, that sounds good, but did you also check out #7? I'm afraid without any proper unit tests here for that PR specifically, we could be doing double-free here.

I actually totally forgot about #6 to continue diving in the dartvm code, but anyway, is there a way you can make a small test for this?

@trueb2
Copy link
Contributor Author

trueb2 commented Apr 14, 2022

Hi @shekohex, Thanks for supporting this project! I really appreciate the ability to integrate async Rust with Flutter.

I ran the change for a couple days with real-world data and added calls to post before the store pointer is set, other than that I don't add more test cases. The current container tests already simulates the VM calling the finalizer. We could still mock a random failure into the post interface and assert success and failure appropriately.

Failure to post or retry post could end up leaking expensive Dart allocations waiting for a message on the native port. I am thinking that the post function or another exposed function should block until success.

I see cargo fmt touched several files. Do you want me to keep or remove those changes?

@shekohex
Copy link
Owner

see cargo fmt touched several files. Do you want me to keep or remove those changes?

Try cargo +nightly fmt since we use nightly in the CI for now.

@shekohex
Copy link
Owner

Failure to post or retry post could end up leaking expensive Dart allocations waiting for a message on the native port. I am thinking that the post function or another exposed function should block until success.

To be honest I see this as a really rare case, where the post message fails, but of cource it exist and could happen. And for that I guess we leave it as is and it is up to the caller to check if returns false they should retry calling it again. so it is up to the app developer here.

Copy link
Owner

@shekohex shekohex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

will publish a new beta version soon!

@shekohex shekohex merged commit 7942065 into shekohex:master Apr 14, 2022
@trueb2 trueb2 deleted the patch-1 branch April 22, 2022 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants