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

[stdlib][runtime] fix uninitialized variable savedSize #4535

Merged
merged 1 commit into from
Aug 31, 2016

Conversation

bryonglodencissp
Copy link

On line number 2560 of Metadata.cpp, savedSize is accessed without an initialized value. It's always good to initialize variables, because if we try to access a value before it gets assigned any actual (non-garbage) value, then it results in undefined behavior.

Found by https://github.com/bryongloden/cppcheck

[stdlib/public/runtime/Metadata.cpp:2560]: (error) Uninitialized variable: savedSize
@gottesmm
Copy link
Contributor

I am not sure if this is actually undefined behavior. The value is being captured by reference in the lambda and is initialized strictly before the lambda runs. @rjmccall/@DougGregor what do you guys think?

@bryonglodencissp
Copy link
Author

It's also worth noting that we've done extensive studies, and 60% of the time our static analysis tool works all the time. Furthermore, sound and complete static analysis is shown to be undecidable, ergo we're led to a few false positives because we've adopted some unsound techniques in our tool.

@gottesmm
Copy link
Contributor

I talked with Doug/etc and we are pretty sure this is not undefined behavior. But that being said, all it would take is a little refactoring to introduce the undefined behavior and also we appreciate you running the tool (so if it quiets the error sounds good).

@gottesmm
Copy link
Contributor

@swift-ci Please smoke test and merge

@swift-ci swift-ci merged commit ab59308 into swiftlang:master Aug 31, 2016
kateinoigakukun added a commit that referenced this pull request Aug 31, 2022
[pull] swiftwasm from main
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