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

UB when editor is launched #2447

Closed
matthiaskrgr opened this issue Feb 5, 2018 · 0 comments
Closed

UB when editor is launched #2447

matthiaskrgr opened this issue Feb 5, 2018 · 0 comments

Comments

@matthiaskrgr
Copy link
Contributor

wesnoth @ d9d67f0

 UBSAN_OPTIONS=print_stacktrace=1 ./build/wesnoth -e
Battle for Wesnoth v1.13.11 (d9d67f0b95-Clean)
Started on Mon Feb  5 14:58:04 2018

Automatically found a possible data directory at /home/matthias/vcs/github/wesnoth/build/..

Data directory:               /home/matthias/vcs/github/wesnoth/build/..
User configuration directory: /home/matthias/.config/wesnoth
User data directory:          /home/matthias/.local/share/wesnoth/1.13
Cache directory:              /home/matthias/.cache/wesnoth

Setting mode to 800x860
Checking lua scripts... ok
../src/game_display.hpp:47:10: runtime error: downcast of address 0x61e0000e7080 which does not point to an object of type 'game_display'
0x61e0000e7080: note: object is of type 'editor::editor_display'
 55 00 80 01  d0 b2 bc 00 00 00 00 00  01 00 be be 00 00 00 00  80 f4 1a 00 d0 61 00 00  10 5c 3c 00
              ^~~~~~~~~~~~~~~~~~~~~~~
              vptr for 'editor::editor_display'
    #0 0x521e7bc in game_display::get_singleton() /home/matthias/vcs/github/wesnoth/build/../src/game_display.hpp:47:10
    #1 0x96a0e2c in image::getMinimap(int, int, gamemap const&, team const*, std::map<map_location, unsigned int, std::less<map_location>, std::allocator<std::pair<map_location const, unsigned int> > > const*, bool) /home/matthias/vcs/github/wesnoth/build/../src/minimap.cpp:87:27
    #2 0x923a63c in display::draw_minimap() /home/matthias/vcs/github/wesnoth/build/../src/display.cpp:1803:14
    #3 0x923837a in display::draw_wrap(bool, bool) /home/matthias/vcs/github/wesnoth/build/../src/display.cpp:1700:3
    #4 0x9217cfe in display::draw(bool, bool) /home/matthias/vcs/github/wesnoth/build/../src/display.cpp:2520:2
    #5 0x921963a in display::redraw_everything() /home/matthias/vcs/github/wesnoth/build/../src/display.cpp:2449:2
    #6 0x5aa88e0 in editor::editor_controller::editor_controller(config const&) /home/matthias/vcs/github/wesnoth/build/../src/editor/controller/editor_controller.cpp:89:8
    #7 0x5968a32 in editor::start(config const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/matthias/vcs/github/wesnoth/build/../src/editor/editor_main.cpp:36:21
    #8 0x51bc97d in game_launcher::start_editor(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/matthias/vcs/github/wesnoth/build/../src/game_launcher.cpp:1004:29
    #9 0x51bc32f in game_launcher::goto_editor() /home/matthias/vcs/github/wesnoth/build/../src/game_launcher.cpp:757:7
    #10 0x4ec2323 in do_gameloop(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&) /home/matthias/vcs/github/wesnoth/build/../src/wesnoth.cpp:827:12
    #11 0x4ebc9eb in main /home/matthias/vcs/github/wesnoth/build/../src/wesnoth.cpp:1150:19
    #12 0x7fe33a0a6889 in __libc_start_main (/lib64/libc.so.6+0x20889)
    #13 0x4de6029 in _start (/home/matthias/vcs/github/wesnoth/build/wesnoth+0x4de6029)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/game_display.hpp:47:10 in 

@Vultraz Vultraz closed this as completed in b04bc7d Feb 5, 2018
Vultraz added a commit that referenced this issue Feb 5, 2018
The proliferation of game_display::get_singleton() was due to 786233d
where I replaced resources::screen (itself a game_display* pointer) with the game_display singleton.

Using the game_display pointer has already caused one case of UB (issue #2447), so I figured it best to
call the base class pointer in all cases where a game_display-specific function or override was not used.
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

No branches or pull requests

1 participant