Fix .NET interop issue for Windows release builds.
For Windows release builds, the `wasm_valtype_kind` C API return value is being returned as a single byte. The .NET interop signature for this function was expecting an integer-sized return, resulting in three extra bytes being used on Windows. The fix is to limit the corresponding C# enum to a byte representation, which will properly mask the return value from `wasm_valtype_kind`. CI has also been updated to test both debug and release configurations (previously it was only testing debug, hence why this was missed). Also fixed a cast bug in the `declare_vec!` macro in the C API when the element types were pointers to values. The `as_slice` implementation was incorrectly casting away a level of pointer indirection, resulting in corrupted data when accessing the slice's elements.
This commit is contained in:
@@ -56,7 +56,7 @@ macro_rules! declare_vec {
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn as_slice(&self) -> &[$elem_ty] {
|
||||
unsafe { slice::from_raw_parts(self.data as *const $elem_ty, self.size) }
|
||||
unsafe { slice::from_raw_parts(self.data, self.size) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,8 +122,8 @@ macro_rules! declare_vec {
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn as_slice(&self) -> &[$elem_ty] {
|
||||
unsafe { slice::from_raw_parts(self.data as *const $elem_ty, self.size) }
|
||||
fn as_slice(&self) -> &[*mut $elem_ty] {
|
||||
unsafe { slice::from_raw_parts(self.data, self.size) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user