-
Notifications
You must be signed in to change notification settings - Fork 18
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
Make zero-copy
and ZeroCopyBuffer
work with Vec<T>
of length 0
#48
Conversation
zero-copy
work with Vec
of length 0zero-copy
work with Vec<T>
of length 0
zero-copy
work with Vec<T>
of length 0zero-copy
and ZeroCopyBuffer
work with Vec<T>
of length 0
So casting to |
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
Did you test this branch with your code? is that fixes your bug? |
I tested with the code provided in this issue, which should obviously work. The code just simply involved passing zero-length |
Will publish a new version very soon. |
Thanks for notifying :) |
Published as v0.1.20 🎉 |
Summary
When enabling the
zero-copy
feature or usingZeroCopyBuffer
,Vec<T>
with length of 0 always made the Dart-Rust app crash. This turned out to be a behavior withisolate_callback_data
, which returns proper length value when the length ofVec<T>
was not 0, but returns an oddly big number whenVec<T>
has zero length.cunarist/rinf#165
Experiment
Adding some
println!()
s can help us inspect this problem.When passing in
Vec<T>
of 6 bytes withzero-copy
feature enabled(or usingZeroCopyBuffer
), we get this output:When passing in
Vec<T>
of 0 bytes withzero-copy
feature enabled(or usingZeroCopyBuffer
), we get this output:The length value from Rust
Vec<T>
is correct, but the length value fromisolate_callback_data
is very weird. This led to deallocating memory of a totally wrong location which always made the Dart-Rust app crash.I've confirmed that this change effectively works on an actual project that uses
Vec<T>
of length 0 withzero-copy
. Tests are also added in this PR.