-
Notifications
You must be signed in to change notification settings - Fork 10
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
Implement clock related functions in wasi #307
Conversation
af34d05
to
429129e
Compare
uint64_t newOffset = argv[3].asI32(); | ||
|
||
uvwasi_filesize_t out_addr = *(instance->memory(0)->buffer() + newOffset); | ||
uvwasi_filesize_t* file_size = reinterpret_cast<uvwasi_filesize_t*>(get_memory_pointer(instance, argv[3], sizeof(uvwasi_filesize_t))); |
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.
What if get_memory_pointer
returns a nullptr here?
In WASI functions, when accessing memory, is range always correct?
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.
There is a trick here. All uvwasi functions checks that the input pointers are non NULL:
https://github.com/nodejs/uvwasi/blob/83dd1fc85077346b1f49a8f3f7a6db96cc0d299d/src/uvwasi.c#L1573
So we turn all invalid pointers to null, and that is checked by uvwasi, and it returns with its expected error code. This will even work, if uvwasi changes the return code.
|
||
char** uvEnviron = reinterpret_cast<char**>(instance->memory(0)->buffer() + env); | ||
char* uvEnvironBuf = reinterpret_cast<char*>(instance->memory(0)->buffer() + environBuf); | ||
TemporaryData pointers(count * sizeof(void*)); |
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.
It seems that TemporaryData
structure is used only here,
so what about simply allocating a temporal buffer inside this environ_get
function?
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.
#308 should also use this. Sharing code should reduce the possible errors.
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 see
429129e
to
d4c9592
Compare
It looks like macos fails with "Error: The |
This might be triggered by |
Improve pointer handling of wasi functions. Signed-off-by: Zoltan Herczeg [email protected]
d4c9592
to
42e2699
Compare
Thank you for the suggestion! The patch is working now |
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.
LGTM
Improve pointer handling of wasi functions.