-
Notifications
You must be signed in to change notification settings - Fork 27.7k
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
ffi not properly decoding Pointer<Char> #152256
Comments
Then I would have expected: const char **udid; And FFIgen would have generated: external ffi.Pointer<ffi.Pointer<ffi.Char>> udid; You can try to verify this by modifying the code to be Side question: Are you sure your string is UTF-8 encoded? You might simply have an ascii string. |
I am sure the sting is null terminated and well formed (looked at the memory in XCode). The string is 0 terminated and is all ascii encoded.. I looked at everything in C using Xcode and the memory viewer. |
Using the pointer to pointer gives an invalid address for the value..
Thats not working either. Of course trying to convert to UTF8 fails.. I have to do a |
Hmmm native callback. How are you dealing with threads here? |
If you're using If you're on the Dart thread you can use We don't have support for arbitrary thread blocking callbacks yet (dart-lang/sdk#54554). |
if I use isolateLocal then i get an error that we can't run callbacks outside the isolate. So basically i need to write some wrappers around the code. |
@dcharkes Should this issue move to dart-lang ? |
👍 Yes, rewriting the code to copy the string and pass ownership to Dart. cc @liamappelbe another use case of where
I think this issue can be closed. @scottandrewzip please let me know if you're still facing issues after passing ownership a copy of the string to Dart. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Steps to reproduce
I trying to use libiMobileDevice using ffi. However it is having trouble with a structure that is passed into the callback. The structure is defined in C as:
when i run ffigen i get the following:
My callback looks like so:
Expected results
I would expect it to derefernce the string properly.
Actual results
The problem is that the
toDartString
fails with missing delimiter. When i poke around a bit the codeUnits are not characters but the address of the string (can verify this by looking at the same code in C in a memory viewer). Pointer<Pointer> doesn't work either. How can i properly decode the string. One more hint in the memory viewer the string is not right after theevent
int. What is after it is a pointer address.Code sample
Code sample
[Paste your code here]
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]
Flutter Doctor output
Doctor output
[Paste your output here]
The text was updated successfully, but these errors were encountered: