Skip to content
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

Incorrect size returned by __wasi_environ_sizes_get #27

Closed
shritesh opened this issue Apr 30, 2019 · 3 comments · Fixed by #128
Closed

Incorrect size returned by __wasi_environ_sizes_get #27

shritesh opened this issue Apr 30, 2019 · 3 comments · Fixed by #128
Labels
bug Something in this repository is erroneous and should be corrected. question Further information is requested

Comments

@shritesh
Copy link

The documentation for __wasi_environ_get says "The sizes of the buffers should match that returned by __wasi_environ_sizes_get" but the WASI implementations that I tested (wasmtime and wasmer) expect a buffer with space for additional null pointer at the end. The sysroot too implements it that way.

This is in contrast with __wasi_args_get and __wasi_args_sizes_get that say the same thing but do as documented.

I'm not sure if this is a bug or the expected behavior. If it is, it should be documented as such.

@rylev rylev added bug Something in this repository is erroneous and should be corrected. question Further information is requested labels May 8, 2019
@sbc100
Copy link
Member

sbc100 commented May 29, 2019

The C arrays exposed to user code for environ and argv are are both defined to be NULL terminated.

I agree it is currently unclear whether the NULL termination is the responsibility of the __wasi_environ_get/__wasi_args_get syscalls, or of the calling code (i.e. the code in crt1.c).

@devsnek
Copy link
Member

devsnek commented May 29, 2019

recently tripped me up as well while implementing this

@peterhuene
Copy link
Contributor

Based on @sunfishcode's earlier comment, I think it's best to not force WASI into a convention that might be viewed as an implementation detail for a libc implementation.

I've put up #128 so we can discuss this further.

sunfishcode pushed a commit that referenced this issue Oct 31, 2019
…128)

This commit updates the documentation for `__wasi_args_get` and
`__wasi_environ_get` to make it explicit that it is the caller's responsibility
to allocate a terminating NULL pointer, if necessary.

Fixes #27.
alexcrichton pushed a commit to alexcrichton/WASI that referenced this issue Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something in this repository is erroneous and should be corrected. question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants