-
Notifications
You must be signed in to change notification settings - Fork 261
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
Does Function that return buffer with string should include trailling 0 or not #492
Comments
Can this be added as point of discussion for the next WASI meeting @linclark @lukewagner? We'd like to know which way is the proper one to make sure the Wasmer WASI implementation respect the specs, and right now is not clear on what the official way is |
@syrusakbary please follow the procedure for adding a discussion topic (adding a PR to the agenda in the meetings repo) |
Here we go: WebAssembly/meetings#1094 |
wasi-libc has code for fd_prestat_dir_name and fd_readdir to insert trailing NUL's in the places where it needs them to be. In languages other than C, strings aren't usually NUL-terminated, so their use of Consequently, I propose Wasmtime's current behavior in these two instances be considered the correct behavior. |
Well, the terminated 0 needs to be set, either on wasm side or the wash side. In my opinion, the definition of "String" should be unified accross the API. At no point is the string defined, and because there isn't any hint of "sized-based" string definition (like could be found in Pascal langage), the assumption is that string are C-like 0-terminated. It would be good to have clarification about all the string buffers. |
@ptitSeb It might be good to have some context on what you're trying to do, as that will help understand what exact information you need. You're right that strings aren't defined in WASI. That is by design. Instead of having a concrete definition of strings in WASI, there is an abstract string type, and that is defined in a different part of the WebAssembly standards, the component model. As stated in the README, we are currently in the process of switching from the initial
If you want to learn more about the thinking behind these types, you can read this post or dig into the component model repo. |
I'm trying to maintain a wasi implementation. But the spec are still not completely consistant. For example, the I dug a bit the component model, but the only thing I found bout string is "list of char" which is still not precise on how you delimit the end of the string (sized or 0-terminated). |
in the mvp of the component model, in memory, a string is two see the definition of |
Yeah, so basically, If I sum-up:
|
There are a few functions, like
fd_prestat_dir_name
orfd_readdir
that fill in buffer with string representing file names. The specs doesn't precised is the buffer include or not the trailling zero. What should it be? with or without the trailling 0?The text was updated successfully, but these errors were encountered: