-
Notifications
You must be signed in to change notification settings - Fork 10
Description
At the moment runtimes can access stack boundaries reading by reading __heap_base
/__data_end
(or __stack_high
/__stack_low
) globals (if they're exported). That works for the main thread, but won't work for the threads we spawn with the new wasi_thread_spawn
API.
Having access to stack boundaries and the stack pointer (which is also not straightforward to retrieve, but possible) would allow runtimes to detect stack overflow or underflow. However, that would slightly complicate the API (we'd probably have to add another parameter to wasi_thread_spawn
).
I personally see a lot of value in having stack overrun (mainly overflow, but underflow can happen too) protection in VMs, but at the same time I'm in favor of having the API simple, at least for now.
I'd like to know others' opinion and see if I didn't miss anything obvious here.
Just a note here - POSIX's pthread_create allows to have a guard memory which prevents from stack overflow, but I don't think this is going to work on WASM as it's not possible to specify read-only memory segments (or is it?).