Skip to content

main: don't mutate compile options in Test#5468

Open
jakebailey wants to merge 1 commit into
tinygo-org:devfrom
jakebailey:test-options-copy
Open

main: don't mutate compile options in Test#5468
jakebailey wants to merge 1 commit into
tinygo-org:devfrom
jakebailey:test-options-copy

Conversation

@jakebailey

Copy link
Copy Markdown
Member

This function modifies TestConfig, but Test is called from multiple places, so can cause a data race. (and in the presence of races, all behavior bets are off).

Comment thread main.go
Comment on lines +212 to +213
optionsCopy := *options
options = &optionsCopy

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This fix works, but leaves the footgun. If it weren't for its size, compileopts.Options should be passed by value.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It probably wouldn't be a big deal to just make it a value arg; either way it's going to get copied...

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.

2 participants