-
Notifications
You must be signed in to change notification settings - Fork 211
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
C# Fixes wasi http header bug and adds a test for it #1215
base: main
Are you sure you want to change the base?
C# Fixes wasi http header bug and adds a test for it #1215
Conversation
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.
Is the fix here around the alignment? How was the issue presenting?
@@ -889,13 +889,13 @@ impl Bindgen for FunctionBindgen<'_, '_> { | |||
" | |||
void* {address}; | |||
if (({size} * {list}.Count) < 1024) {{ | |||
var {ret_area} = stackalloc {element_type}[({array_size}*{list}.Count)+1]; |
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.
looks like this moved the logic to add the additional 1 to the dotnet_aligned_array
function, we should update
wit-bindgen/crates/csharp/src/function.rs
Line 1294 in 6541e44
var {ret_area} = stackalloc {element_type}[{array_size}+1]; |
@@ -889,13 +889,13 @@ impl Bindgen for FunctionBindgen<'_, '_> { | |||
" | |||
void* {address}; | |||
if (({size} * {list}.Count) < 1024) {{ | |||
var {ret_area} = stackalloc {element_type}[({array_size}*{list}.Count)+1]; | |||
{address} = (void*)(((int){ret_area}) + ({align} - 1) & -{align}); |
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.
I believe this line is still required or in some cases this won't align properly since stackalloc
won't align on the correct memory boundary (dotnet/csharplang#1799). Unless something else is subtly addressing this?
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.
Refactor void* AlignStackPtr(void* stackAddress, uint alignment)
helper and use it everywhere.
@@ -754,7 +754,7 @@ impl Bindgen for FunctionBindgen<'_, '_> { | |||
" | |||
); | |||
} | |||
results.push(format!("(nint){ptr}")); | |||
results.push(format!("(int){ptr}")); |
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.
why this change?
@@ -26,6 +26,8 @@ interface test { | |||
list-roundtrip: func(a: list<u8>) -> list<u8>; | |||
|
|||
string-roundtrip: func(a: string) -> string; | |||
|
|||
wasi-http-headers-roundtrip: func(a: list<tuple<string, list<u8>>>) -> list<tuple<string, list<u8>>>; |
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.
will need to add this to https://github.com/bytecodealliance/wit-bindgen/tree/main/tests/runtime-new/lists since this test has moved to the new framework #1221
Fixes a bug where headers returned from a C# component wouldn't be properly set. Adds a test for it and some cleanup.