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

wasi_thread_start: add a comment #371

Merged
merged 1 commit into from
Dec 23, 2022

Conversation

yamt
Copy link
Contributor

@yamt yamt commented Dec 22, 2022

No description provided.

Verified

This commit was signed with the committer’s verified signature.
wpoynter Will Poynter
Copy link
Member

@sbc100 sbc100 left a 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.

@yamt
Copy link
Contributor Author

yamt commented Dec 22, 2022

Hmm.. perhaps we should use a .S or .s file here?

probably yes.

@yamt
Copy link
Contributor Author

yamt commented Dec 23, 2022

Hmm.. perhaps we should use a .S or .s file here?

probably yes.

once the api/abi got stable.

@abrown abrown merged commit ebd3240 into WebAssembly:main Dec 23, 2022
* 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.
*/
Copy link
Contributor

@loganek loganek Jan 5, 2023

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

john-sharratt pushed a commit to john-sharratt/wasix-libc that referenced this pull request Mar 6, 2023

Verified

This commit was signed with the committer’s verified signature.
wpoynter Will Poynter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants