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

[Crash]: Clicking any building buttons in the top menu crashes the game if window height is too small #9632

Closed
ldpl opened this issue Oct 20, 2021 · 2 comments · Fixed by #10934
Labels
bug Something isn't working

Comments

@ldpl
Copy link
Contributor

ldpl commented Oct 20, 2021

Version of OpenTTD

master (e68a51e)

Expected result

Not crash/assert.

Actual result

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff727b859 in __GI_abort () at abort.c:79
#2  0x00007ffff727b729 in __assert_fail_base (fmt=0x7ffff7411588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55555688dec0 "available_height >= avg_height", 
    file=0x55555688de18 "/home/pavels/Projects/OpenTTD/src/widgets/dropdown.cpp", line=403, function=<optimized out>) at assert.c:92
#3  0x00007ffff728cf36 in __GI___assert_fail (assertion=0x55555688dec0 "available_height >= avg_height", file=0x55555688de18 "/home/pavels/Projects/OpenTTD/src/widgets/dropdown.cpp", 
    line=403, function=0x55555688de68 "void ShowDropDownListAt(Window*, DropDownList&&, int, int, Rect, Colours, bool, bool)") at assert.c:101
#4  0x000055555600a3af in ShowDropDownListAt (w=0x7fffbceef1f0, list=..., selected=0, button=21, wi_rect=..., wi_colour=COLOUR_GREY, auto_width=true, instant_close=true)
    at /home/pavels/Projects/OpenTTD/src/widgets/dropdown.cpp:403
#5  0x000055555600a656 in ShowDropDownList (w=0x7fffbceef1f0, list=..., selected=0, button=21, width=140, auto_width=true, instant_close=true)
    at /home/pavels/Projects/OpenTTD/src/widgets/dropdown.cpp:466
#6  0x000055555643f556 in ToolbarBuildRailClick (w=0x7fffbceef1f0) at /home/pavels/Projects/OpenTTD/src/toolbar_gui.cpp:861
#7  0x00005555564434a0 in MainToolbarWindow::OnClick (this=0x7fffbceef1f0, pt=..., widget=21, click_count=1) at /home/pavels/Projects/OpenTTD/src/toolbar_gui.cpp:1987
#8  0x00005555564e8616 in DispatchLeftClickEvent (w=0x7fffbceef1f0, x=1844, y=43, click_count=1) at /home/pavels/Projects/OpenTTD/src/window.cpp:786
#9  0x00005555564ee796 in MouseLoop (click=MC_LEFT, mousewheel=0) at /home/pavels/Projects/OpenTTD/src/window.cpp:2889
#10 0x00005555564eeb9c in HandleMouseEvents () at /home/pavels/Projects/OpenTTD/src/window.cpp:2986
#11 0x0000555555fffa8b in VideoDriver_SDL_Base::PollEvent (this=0x555558b51d70) at /home/pavels/Projects/OpenTTD/src/video/sdl2_v.cpp:406
#12 0x0000555556007b09 in VideoDriver::Tick (this=0x555558b51d70) at /home/pavels/Projects/OpenTTD/src/video/video_driver.cpp:133
#13 0x00005555560003be in VideoDriver_SDL_Base::LoopOnce (this=0x555558b51d70) at /home/pavels/Projects/OpenTTD/src/video/sdl2_v.cpp:614
#14 0x000055555600040b in VideoDriver_SDL_Base::MainLoop (this=0x555558b51d70) at /home/pavels/Projects/OpenTTD/src/video/sdl2_v.cpp:632
#15 0x000055555629156d in openttd_main (argc=1, argv=0x7fffffffdda8) at /home/pavels/Projects/OpenTTD/src/openttd.cpp:802
#16 0x0000555555eb6ff7 in main (argc=1, argv=0x7fffffffdda8) at /home/pavels/Projects/OpenTTD/src/os/unix/unix.cpp:262

Steps to reproduce

  1. Start the new game
  2. Resize widow so that status bar almost meets main toolbar.
  3. Click any building button (rail/road/tram/air/ship)

Screenshot from 2021-10-20 16-27-19

@ldpl ldpl changed the title [Crash]: Clicking any building buttons in the top menu crashes if game window hight is too small [Crash]: Clicking any building buttons in the top menu crashes the game if window hight is too small Oct 20, 2021
@ldpl
Copy link
Contributor Author

ldpl commented Oct 20, 2021

And if resized even further it starts crashing on hovering:

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff727b859 in __GI_abort () at abort.c:79
#2  0x00007ffff727b729 in __assert_fail_base (fmt=0x7ffff7411588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x555556a560b5 "min <= max", 
    file=0x555556a56080 "/home/pavels/Projects/OpenTTD/src/core/math_func.hpp", line=79, function=<optimized out>) at assert.c:92
#3  0x00007ffff728cf36 in __GI___assert_fail (assertion=0x555556a560b5 "min <= max", file=0x555556a56080 "/home/pavels/Projects/OpenTTD/src/core/math_func.hpp", line=79, 
    function=0x555556a56060 "T Clamp(T, T, T) [with T = int]") at assert.c:101
#4  0x00005555561c0c78 in Clamp<int> (a=95, min=85, max=41) at /home/pavels/Projects/OpenTTD/src/core/math_func.hpp:79
#5  0x00005555561bf2cb in Clamp (a=95, min=85, max=41) at /home/pavels/Projects/OpenTTD/src/core/math_func.hpp:103
#6  0x00005555561c4942 in TooltipsWindow::OnInitialPosition (this=0x5555591d5be0, sm_width=234, sm_height=33, window_number=0) at /home/pavels/Projects/OpenTTD/src/misc_gui.cpp:703
#7  0x00005555564eb29d in Window::FinishInitNested (this=0x5555591d5be0, window_number=0) at /home/pavels/Projects/OpenTTD/src/window.cpp:1780
#8  0x00005555564eb357 in Window::InitNested (this=0x5555591d5be0, window_number=0) at /home/pavels/Projects/OpenTTD/src/window.cpp:1792
#9  0x00005555561c4891 in TooltipsWindow::TooltipsWindow (this=0x5555591d5be0, parent=0x7fff9c7a7f20, str=287, paramcount=0, params=0x0, close_tooltip=TCC_HOVER)
    at /home/pavels/Projects/OpenTTD/src/misc_gui.cpp:685
#10 0x00005555561bfbf6 in GuiShowTooltips (parent=0x7fff9c7a7f20, str=287, paramcount=0, params=0x0, close_tooltip=TCC_HOVER) at /home/pavels/Projects/OpenTTD/src/misc_gui.cpp:773
#11 0x00005555564e88c3 in DispatchHoverEvent (w=0x7fff9c7a7f20, x=1847, y=18) at /home/pavels/Projects/OpenTTD/src/window.cpp:832
#12 0x00005555564ee807 in MouseLoop (click=MC_HOVER, mousewheel=0) at /home/pavels/Projects/OpenTTD/src/window.cpp:2903
#13 0x00005555564eeb9c in HandleMouseEvents () at /home/pavels/Projects/OpenTTD/src/window.cpp:2986
#14 0x00005555564eed94 in InputLoop () at /home/pavels/Projects/OpenTTD/src/window.cpp:3042
#15 0x0000555556007b83 in VideoDriver::Tick (this=0x555558b4aa80) at /home/pavels/Projects/OpenTTD/src/video/video_driver.cpp:145
#16 0x00005555560003be in VideoDriver_SDL_Base::LoopOnce (this=0x555558b4aa80) at /home/pavels/Projects/OpenTTD/src/video/sdl2_v.cpp:614
#17 0x000055555600040b in VideoDriver_SDL_Base::MainLoop (this=0x555558b4aa80) at /home/pavels/Projects/OpenTTD/src/video/sdl2_v.cpp:632
#18 0x000055555629156d in openttd_main (argc=1, argv=0x7fffffffdda8) at /home/pavels/Projects/OpenTTD/src/openttd.cpp:802
#19 0x0000555555eb6ff7 in main (argc=1, argv=0x7fffffffdda8) at /home/pavels/Projects/OpenTTD/src/os/unix/unix.cpp:262

Screenshot from 2021-10-20 16-42-26

@TrueBrain TrueBrain changed the title [Crash]: Clicking any building buttons in the top menu crashes the game if window hight is too small [Crash]: Clicking any building buttons in the top menu crashes the game if window height is too small Oct 20, 2021
@James103
Copy link
Contributor

Likely same or similar assertions as #8869, given the backtraces. The game crashes because there is not enough space to:

  • Display the tooltip in full (first case)
  • Display at least one item of the dropdown (second case)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants