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 when trying to use a newgrf object #8276

Closed
ldpl opened this issue Jul 19, 2020 · 1 comment
Closed

Crash when trying to use a newgrf object #8276

ldpl opened this issue Jul 19, 2020 · 1 comment

Comments

@ldpl
Copy link
Contributor

@ldpl ldpl commented Jul 19, 2020

Version of OpenTTD

1.10.2 and master(4079c47)

Expected result

There is probably something wrong with this grf but it shouldn't crash the game nonetheless.

Actual result

openttd: /home/dp/Projects/OpenTTD/src/viewport.cpp:1974: void SetSelectionTilesDirty(): Assertion `x_size >= 0' failed.

Thread 1 "openttd" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50  ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff7274859 in __GI_abort () at abort.c:79
#2  0x00007ffff7274729 in __assert_fail_base (fmt=0x7ffff740a588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x5555566a874a "x_size >= 0", 
    file=0x5555566a7c08 "/home/dp/Projects/OpenTTD/src/viewport.cpp", line=1974, function=<optimized out>) at assert.c:92
#3  0x00007ffff7285f36 in __GI___assert_fail (assertion=0x5555566a874a "x_size >= 0", file=0x5555566a7c08 "/home/dp/Projects/OpenTTD/src/viewport.cpp", line=1974, 
    function=0x5555566a872c "void SetSelectionTilesDirty()") at assert.c:101
#4  0x0000555556061216 in SetSelectionTilesDirty () at /home/dp/Projects/OpenTTD/src/viewport.cpp:1974
#5  0x000055555606305f in UpdateTileSelection () at /home/dp/Projects/OpenTTD/src/viewport.cpp:2582
#6  0x000055555608b386 in MouseLoop (click=MC_NONE, mousewheel=0) at /home/dp/Projects/OpenTTD/src/window.cpp:2883
#7  0x000055555608bafd in HandleMouseEvents () at /home/dp/Projects/OpenTTD/src/window.cpp:3050
#8  0x0000555555cb3e07 in VideoDriver_SDL::PollEvent (this=0x5555583f3560) at /home/dp/Projects/OpenTTD/src/video/sdl2_v.cpp:511
#9  0x0000555555cb44f8 in VideoDriver_SDL::MainLoop (this=0x5555583f3560) at /home/dp/Projects/OpenTTD/src/video/sdl2_v.cpp:714
#10 0x0000555555ec2edd in openttd_main (argc=1, argv=0x7fffffffdda8) at /home/dp/Projects/OpenTTD/src/openttd.cpp:844
#11 0x0000555555bcf4d6 in main (argc=1, argv=0x7fffffffdda8) at /home/dp/Projects/OpenTTD/src/os/unix/unix.cpp:261
(gdb) frame 4
#4  0x0000555556061216 in SetSelectionTilesDirty () at /home/dp/Projects/OpenTTD/src/viewport.cpp:1974
1974            assert(x_size >= 0);
(gdb) l
1969            }
1970    
1971            x_size -= TILE_SIZE;
1972            y_size -= TILE_SIZE;
1973    
1974            assert(x_size >= 0);
1975            assert(y_size >= 0);
1976    
1977            int x_end = Clamp(x_start + x_size, 0, MapSizeX() * TILE_SIZE - TILE_SIZE);
1978            int y_end = Clamp(y_start + y_size, 0, MapSizeY() * TILE_SIZE - TILE_SIZE);
(gdb) p x_size
$1 = -16
(gdb) p y_size
$2 = -16
(gdb) p _thd
$3 = {pos = {x = 512, y = 784}, size = {x = 0, y = 0}, offs = {x = 0, y = 0}, outersize = {x = 0, y = 0}, diagonal = false, freeze = false, new_pos = {x = 512, y = 784}, new_size = {x = 0, y = 0}, 
  new_outersize = {x = 0, y = 0}, dirty = 255 '\377', selstart = {x = 0, y = 0}, selend = {x = 0, y = 0}, sizelimit = 0 '\000', drawstyle = HT_RECT, next_drawstyle = HT_NONE, place_mode = HT_RECT, 
  window_class = WC_BUILD_OBJECT, window_number = 0, make_square_red = false, redsq = 4294967295, select_method = VPM_X_OR_Y, select_proc = DDSP_DEMOLISH_AREA}

Steps to reproduce

Start a game with crash_test.grf, try to build an object
crash_test.zip

@ldpl
Copy link
Contributor Author

@ldpl ldpl commented Jul 19, 2020

Figured out what was wrong with grf: I forgot to set object size, after adding size: [1,1]; it works just fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants