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 missing was_loaded initialization #36440

Merged
merged 4 commits into from
Dec 26, 2019

Conversation

hexagonrecursion
Copy link
Contributor

@hexagonrecursion hexagonrecursion commented Dec 25, 2019

Summary

SUMMARY: Bugfixes "Fix uninitialized memory access when loading from json"

Purpose of change

To trigger the bug compile with clang UndefinedBehaviorSanitizer and start a new game. On the console you'll see

src/json.cpp:438:26: runtime error: load of value 194, which is not a valid value for type 'bool'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/json.cpp:438:26 in 
src/magic_enchantment.cpp:196:19: runtime error: load of value 224, which is not a valid value for type 'bool'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/magic_enchantment.cpp:196:19 in 
src/clzones.cpp:133:20: runtime error: load of value 224, which is not a valid value for type 'bool'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/clzones.cpp:133:20 in 
src/clzones.cpp:134:20: runtime error: load of value 224, which is not a valid value for type 'bool'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/clzones.cpp:134:20 in 
src/clzones.cpp:135:19: runtime error: load of value 224, which is not a valid value for type 'bool'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/clzones.cpp:135:19 in 
src/item_category.cpp:30:20: runtime error: load of value 192, which is not a valid value for type 'bool'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/item_category.cpp:30:20 in 
src/item_category.cpp:31:19: runtime error: load of value 192, which is not a valid value for type 'bool'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/item_category.cpp:31:19 in 
src/item_category.cpp:32:19: runtime error: load of value 192, which is not a valid value for type 'bool'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/item_category.cpp:32:19 in 

src/clzones.cpp:133:20: runtime error: load of value 224, which is not a valid value for type 'bool'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/clzones.cpp:133:20 in 
src/clzones.cpp:134:20: runtime error: load of value 224, which is not a valid value for type 'bool'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/clzones.cpp:134:20 in 
src/clzones.cpp:135:19: runtime error: load of value 224, which is not a valid value for type 'bool'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/clzones.cpp:135:19 in
src/json.cpp:438:26: runtime error: load of value 194, which is not a valid value for type 'bool'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/json.cpp:438:26 in
src/magic_enchantment.cpp:196:19: runtime error: load of value 224, which is not a valid value for type 'bool'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/magic_enchantment.cpp:196:19 in
src/item_category.cpp:30:20: runtime error: load of value 192, which is not a valid value for type 'bool'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/item_category.cpp:30:20 in 
src/item_category.cpp:31:19: runtime error: load of value 192, which is not a valid value for type 'bool'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/item_category.cpp:31:19 in 
src/item_category.cpp:32:19: runtime error: load of value 192, which is not a valid value for type 'bool'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/item_category.cpp:32:19 in
@Qrox
Copy link
Contributor

Qrox commented Dec 25, 2019

I'm surprised that neither the compilers nor clang-tidy gives any warning about these uninitialized values.

@hexagonrecursion
Copy link
Contributor Author

The tests are failing. Have I messed something up?

@ZhilkinSerg ZhilkinSerg added <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` labels Dec 25, 2019
@ZhilkinSerg
Copy link
Contributor

The tests are failing. Have I messed something up?

Nope. There are some things in json that needs to be fixed.

@ZhilkinSerg ZhilkinSerg merged commit ce7512f into CleverRaven:master Dec 26, 2019
@hexagonrecursion hexagonrecursion deleted the patch-1 branch December 26, 2019 09:08
@jbytheway
Copy link
Contributor

I'm surprised that neither the compilers nor clang-tidy gives any warning about these uninitialized values.

We should enable UBSan on the clang test that currently uses ASan. At the time I creawted that test I didn't know it was possible to enable both together, but apparently it is.

It's on my todo list, but someone else is welcome to do it. @hexagonrecursion how many UBSan errors did you see when trying this? Will it be a lot of work to fix any others?

@hexagonrecursion
Copy link
Contributor Author

@jbytheway You caught me. I am indeed guilty of sitting on unreported UBSan errors. I'll report them soon (tm).

@hexagonrecursion
Copy link
Contributor Author

hexagonrecursion commented Jan 8, 2020

@jbytheway I got round to reporting the ones I can still reproduce #36807 #36808 #36809.

@hexagonrecursion
Copy link
Contributor Author

@jagoly And now I'm sitting on a fresh batch of unreported UBSan warnings again. Will keep reporting.

@hexagonrecursion
Copy link
Contributor Author

@jbytheway I have several unreported UBSan errors with lldb stack traces that I did not report because I am unable to reliably reproduce them. Should I report them anyway?

@jbytheway
Copy link
Contributor

Are they coming from running the game or the tests? In the short term, I'd be more concerned with ones that arise in the tests, because those are the ones we need to fix to be able to turn on UBSan in the continuous integration testing. And ones you see in the tests ought to be easier to reproduce (hopefully...).

@hexagonrecursion
Copy link
Contributor Author

@jbytheway they are from running the game.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants