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]: Assertion failure scrolling to collapsed variant in autoreplace window #10554

Closed
JGRennison opened this issue Mar 8, 2023 · 0 comments

Comments

@JGRennison
Copy link
Contributor

Version of OpenTTD

master

Steps to reproduce

  1. Add a NewGRF which uses vehicle variants
  2. Open the autoreplace window
  3. Expand a vehicle variant in the right panel
  4. Set an autoreplace for a vehicle in the left panel to a non top-level vehicle in the right panel
  5. Collapse the vehicle variant in the right panel
  6. Click another vehicle in the left panel
  7. Click the vehicle with the autoreplace applied above in the left panel

See:

this->vscroll[1]->SetCount((uint)this->engines[1].size());
if (this->reset_sel_engine && this->sel_engine[1] != INVALID_ENGINE) {
int position = 0;
for (const auto &item : this->engines[1]) {
if (item.engine_id == this->sel_engine[1]) break;
++position;
}
this->vscroll[1]->ScrollTowards(position);

position is liable to be the same as GetCount()

Upload crash files

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff7104859 in __GI_abort () at abort.c:79
#2  0x00007ffff7104729 in __assert_fail_base
    (fmt=0x7ffff729a588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x555555e53bd0 "this->count <= this->cap ? (position == 0) : (position + this->cap <= this->count)", file=0x555555e94ec0 "/home/jgr/openttd/trunk/src/widget_type.h", line=750, function=<optimised out>) at assert.c:92
#3  0x00007ffff7115fd6 in __GI___assert_fail
    (assertion=assertion@entry=0x555555e53bd0 "this->count <= this->cap ? (position == 0) : (position + this->cap <= this->count)", file=file@entry=0x555555e94ec0 "/home/jgr/openttd/trunk/src/widget_type.h", line=line@entry=750, function=function@entry=0x555555e53ba8 "bool Scrollbar::SetPosition(int)") at assert.c:101
#4  0x0000555555b69a57 in Scrollbar::SetPosition(int) (position=<optimised out>, this=<optimised out>) at /home/jgr/openttd/trunk/src/rail.h:304
#5  Scrollbar::ScrollTowards(int) (position=<optimised out>, this=<optimised out>) at /home/jgr/openttd/trunk/src/widget_type.h:784
#6  ReplaceVehicleWindow::GenerateLists() (this=0x555559138990) at /home/jgr/openttd/trunk/src/autoreplace_gui.cpp:247
#7  ReplaceVehicleWindow::OnPaint() (this=0x555559138990) at /home/jgr/openttd/trunk/src/autoreplace_gui.cpp:486
#8  0x0000555555e3a967 in DrawOverlappedWindow(Window*, int, int, int, int) (w=0x555559138990, left=<optimised out>, top=<optimised out>, right=1113, bottom=619) at /home/jgr/openttd/trunk/src/window.cpp:935
#9  0x0000555555e3bb09 in DrawOverlappedWindowForAll(int, int, int, int) (left=left@entry=613, top=top@entry=301, right=right@entry=1113, bottom=bottom@entry=619) at /home/jgr/openttd/trunk/src/window.cpp:994
#10 0x0000555555bf4d20 in RedrawScreenRect(int, int, int, int) (left=613, top=301, right=1113, bottom=619) at /home/jgr/openttd/trunk/src/gfx.cpp:1625
#11 0x0000555555bf4eb2 in DrawDirtyBlocks() () at /home/jgr/openttd/trunk/src/gfx.cpp:1700
#12 0x0000555555e3def7 in UpdateWindows() () at /home/jgr/openttd/trunk/src/window.cpp:3146
#13 0x0000555555b5390d in VideoDriver::Tick() (this=0x555557b8d0f0) at /home/jgr/openttd/trunk/src/video/video_driver.cpp:149
#14 0x0000555555b4f6b9 in VideoDriver_SDL_Base::LoopOnce() (this=0x555557b8d0f0) at /home/jgr/openttd/trunk/src/video/sdl2_v.cpp:615
#15 VideoDriver_SDL_Base::LoopOnce() (this=0x555557b8d0f0) at /home/jgr/openttd/trunk/src/video/sdl2_v.cpp:594
#16 0x0000555555b4f6e5 in VideoDriver_SDL_Base::MainLoop() (this=0x555557b8d0f0) at /home/jgr/openttd/trunk/src/video/sdl2_v.cpp:633
#17 0x0000555555cd0599 in openttd_main(int, char**) (argc=<optimised out>, argv=<optimised out>) at /home/jgr/openttd/trunk/src/sound/../driver.h:89
#18 0x00007ffff7106083 in __libc_start_main (main=0x5555557a8440 <main(int, char**)>, argc=2, argv=0x7fffffffdb68, init=<optimised out>, fini=<optimised out>, rtld_fini=<optimised out>, stack_end=0x7fffffffdb58)
    at ../csu/libc-start.c:308
#19 0x000055555584499e in _start () at /home/jgr/openttd/trunk/src/os/unix/../../3rdparty/fmt/format.h:822
JGRennison added a commit to JGRennison/OpenTTD-patches that referenced this issue Mar 8, 2023
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