Skip to content

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

Merged
sunfishcode merged 1 commit intoWebAssembly:mainfrom
type-dance:reactor-initialize-runonce-check
Jan 30, 2023
Merged

Add a check to reactor modules to ensure _initialize is only called once#388
sunfishcode merged 1 commit intoWebAssembly:mainfrom
type-dance:reactor-initialize-runonce-check

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 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
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.

3 participants