-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Undefined behavior due to player x coordinate out of range when starting a new game #36570
Comments
Setting x to 0 after the call to But: why is the lightmap generated before the player is placed on the map (hat step give the player a valid location)? Is the lightmap created during character creation? Ideally, we would have a separate data structure that stores the settings done during character creation (traits, profession, ...). This would be stored as template. And it would calculate the stats (to display and to use when the character instance is created) based on that. |
No. u.setx( -1 ) is called from set_stats, which is invoked during character creation when you tab to the "stats" tab of the character creation UI. It is not triggered if you select "play now (fixed scenario)" or "play now". It is not triggered if you select "random character" unless you tab back to the "stats" tab. Here is the stack trace:
map::build_seen_cache is invoked later (after you confirm character creation) while a message "please wait as we build your world" is displayed. Here is the stack trace:
|
Describe the bug
clang UndefinedBehaviorSanitizer complains when starting a game:
Steps To Reproduce
Steps to reproduce the behavior:
Expected behavior
Accessing an array out of bounds is undefined behavior. This should not happen.
Versions and configuration
Dark Days Ahead [dda],
Disable NPC Needs [no_npc_food]
]
Additional context
The UB is triggered because in the following code origin.x is -1
Cataclysm-DDA/src/lightmap.cpp
Lines 1117 to 1124 in 5b3dcd7
build_seen_cache is called from here
Cataclysm-DDA/src/map.cpp
Lines 7702 to 7707 in 869f9b4
I think I tracked down the code responsible for setting player x position to -1
Cataclysm-DDA/src/newcharacter.cpp
Lines 746 to 755 in d136e46
The following questions are yet to be answered:
u.reset()
trying to accomplish?u.setx( -1 )
still necessary now (years later)?u.setx( -1 )
still sufficient?u.setx( 0 )
belowu.reset()
fix everything without breaking something else and starting the vicious cycle all over again?The text was updated successfully, but these errors were encountered: