You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Starting
rust notification size: 24
rust value size: 16
Initializing library
C++ notification size: 24
C++ value size: 16
1 0 0 0 2 0 0 0 3 0 0 0 4 0 0 0 5 6 7 8 9 CC CC CC
1 0 0 0 2 0 0 0 3 0 0 0 4 0 0 0 5 9 48 64 80 CC CC CC
Notification: Notification{notification_type: 1i32, value_id: Value{a: 2u32, b:
3i32, c: 4i32, d: 5u8, e: 9u8, f: 72u8, g: 100u8}, data: 128u8}
The first line is the content of the notification in bytes in C++, the second the content in Rust.
You can see that the last bytes of the notification structure are different in C++ in Rust. Interesting hereby is also that the last field (notification.data == 9) gets copied into notification.value_id.d (verified this with using other values for notification.data) and the remaining notification fields are garbage.
The text was updated successfully, but these errors were encountered:
@sanxiyn on IRC mentioned that this could be related to #9205
However I'm not sure because that issue is about structs as return values. In my case the struct is a function argument and not the return value.
Issue #11198 is also similar.
However I could successfully pass structs from Rust to C before - but mine didn't contain u8 values but only pointers and i32/u32 values.
Maybe the issue is related to u8/i8 types in structs? Because in my example the problem also exists at the first u8 location.
As @eddyb on IRC suggested I have created a more compact example and included LLVM IR: https://gist.github.com/Matthias247/8376787
The error happens on all structs with more than a single u8 or u16 value.
The new test tests are passing a struct with 4 u8 or 4 u16 parameters from Rust to C as well as from C to Rust.
I also switched the C side from a C++ project with extern C declarations to a pure C project, so that this issue can be ruled out.
I'm interfacing an external DLL which I'm creating with Visual Studio 2012.
I've tried to pass a struct by-value from C to Rust in a callback.
The struct and the callback are defined as follows:
However the struct received in
on_notification
is corrupted and contains not the data which is sent in C++.I wrote a test program to isolate and reproduce the issue.
The gist therefore is here: https://gist.github.com/Matthias247/8283183
It can be cloned from https://gist.github.com/8283183.git
It includes the source code for the library with a visual studio project to built it and the rust test program.
I also included make.sh to build it on Linux. However in Linux I can't reproduct the issue. The struct get's copied correctly there.
This is the output from my test program:
The first line is the content of the notification in bytes in C++, the second the content in Rust.
You can see that the last bytes of the notification structure are different in C++ in Rust. Interesting hereby is also that the last field (notification.data == 9) gets copied into notification.value_id.d (verified this with using other values for notification.data) and the remaining notification fields are garbage.
The text was updated successfully, but these errors were encountered: