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

Add a check to reactor modules to ensure _initialize is only called once #388

Merged

Conversation

TerrorJack
Copy link
Contributor

Calling _initialize multiple times is undefined behavior, since the ctors are not guaranteed to be idempotent. We should have this safety check which is similar to #329.

@TerrorJack TerrorJack force-pushed the reactor-initialize-runonce-check branch from 149319f to a5dc0c1 Compare January 25, 2023 17:54
@TerrorJack TerrorJack requested a review from sbc100 January 26, 2023 00:20
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.

Seems reasonable to me. I'll wait @sunfishcode for chime in too though.

@TerrorJack
Copy link
Contributor Author

@sunfishcode 👀

@sunfishcode
Copy link
Member

Sounds like a good idea to me. We should also add code to do this with atomics when ifdef REENTRANT, similar to what crt-command.c now does.

Calling _initialize multiple times is undefined behavior, since the
ctors are not guaranteed to be idempotent. We should have this safety
check which is similar to #329.
@TerrorJack TerrorJack force-pushed the reactor-initialize-runonce-check branch from a5dc0c1 to 7c4c731 Compare January 29, 2023 20:28
@TerrorJack
Copy link
Contributor Author

@sunfishcode The check logic when _REENTRANT has been implemented.

@sunfishcode
Copy link
Member

Thanks!

@sunfishcode sunfishcode merged commit 9bec2d3 into WebAssembly:main Jan 30, 2023
@TerrorJack TerrorJack deleted the reactor-initialize-runonce-check branch January 30, 2023 12:30
abrown added a commit to abrown/wasi-sdk that referenced this pull request Feb 7, 2023
This brings in two recent commits, WebAssembly/wasi-libc#388 and
WebAssembly/wasi-libc#391, that seem useful to have.
abrown added a commit to WebAssembly/wasi-sdk that referenced this pull request Feb 10, 2023
This brings in two recent commits, WebAssembly/wasi-libc#388 and
WebAssembly/wasi-libc#391, that seem useful to have.
john-sharratt pushed a commit to john-sharratt/wasix-libc that referenced this pull request Mar 6, 2023
…nce (WebAssembly#388)

Calling _initialize multiple times is undefined behavior, since the
ctors are not guaranteed to be idempotent. We should have this safety
check which is similar to WebAssembly#329.
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

3 participants