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

Do not skip locals init in state machines #14984

Merged
merged 1 commit into from
Mar 27, 2023
Merged

Do not skip locals init in state machines #14984

merged 1 commit into from
Mar 27, 2023

Conversation

kerams
Copy link
Contributor

@kerams kerams commented Mar 27, 2023

Fixes #13386.

The problem turned out not to be the initobj for TaskAwaiter, but the fact that the code emitted by task builder relies on locals being initialized. Randomly initialized bool flags could result in semi-arbitrary code being executed, like an exception handler despite no exception being thrown.

An alternative solution would have been to manually initialize every local used by the state machine in MoveNext, enabling user code, which is inlined, to potentially benefit from no initialization.

@kerams kerams requested a review from a team as a code owner March 27, 2023 18:33
Copy link
Member

@vzarytovskii vzarytovskii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@psfinaki
Copy link
Member

Thanks @kerams.

@psfinaki psfinaki merged commit 448da58 into dotnet:main Mar 27, 2023
@kerams kerams deleted the nre branch March 27, 2023 19:31
kant2002 pushed a commit to kant2002/fsharp that referenced this pull request Apr 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

NRE in task builder with SkipLocalsInit after certain amount of invocations in Release
3 participants