-
Notifications
You must be signed in to change notification settings - Fork 206
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
wasi_thread_start: add a comment #371
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.
Hmm.. perhaps we should use a .S or .s file here? lgtm to the comment though.
probably yes. |
once the api/abi got stable. |
* Note: it's fragile to implement wasi_thread_start in C. | ||
* On entry, we don't even have C stack (__stack_pointer) | ||
* set up. Be careful when modifying this 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.
I actually wonder if the function, even in its current state, is safe and won't cause memory corruption? Whatever value is currently set to __stack_pointer is not correct; I'd assume the function will reference another thread's (main thread's?) stack (e.g. for local variables?) and overwrite the data. I presume it depends on the compiler or even it's optimization flags. Am I missing something?
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 presume it depends on the compiler or even it's optimization flags.
right. it's what i meant by "fragile".
when i disassembled it, it seemed ok. so i didn't bother to rewrite it in asm for 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.
Yeah, I guess this depends on the optimization level, if you exclude -O2
it actually does include stack operations. I was going to fix that in some of the WAMR examples by implementing the method in asm but then I notice @sbc100 's comment and your followup PR. Thansk.
No description provided.