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

Game asserts/crashes when closed during newgrf scan #8760

Closed
ldpl opened this issue Feb 27, 2021 · 1 comment · Fixed by #8830
Closed

Game asserts/crashes when closed during newgrf scan #8760

ldpl opened this issue Feb 27, 2021 · 1 comment · Fixed by #8830
Milestone

Comments

@ldpl
Copy link
Contributor

@ldpl ldpl commented Feb 27, 2021

Version of OpenTTD

master(4fd2eec)

Expected result

ehm... may be not crash?

Actual result

openttd: /home/pavels/Projects/OpenTTD/src/fileio.cpp:97: void FioSeekToFile(uint8, size_t): Assertion `f != nullptr' failed.

Thread 5 "openttd" received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffff0f89700 (LWP 2977492)]
__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  0x00007ffff7271859 in __GI_abort () at abort.c:79
#2  0x00007ffff7271729 in __assert_fail_base (fmt=0x7ffff7407588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55555642e96d "f != nullptr", 
    file=0x55555642e940 "/home/pavels/Projects/OpenTTD/src/fileio.cpp", line=97, function=<optimized out>) at assert.c:92
#3  0x00007ffff7282f36 in __GI___assert_fail (assertion=0x55555642e96d "f != nullptr", file=0x55555642e940 "/home/pavels/Projects/OpenTTD/src/fileio.cpp", line=97, 
    function=0x55555642e918 "void FioSeekToFile(uint8, size_t)") at assert.c:101
#4  0x0000555555d698c0 in FioSeekToFile (slot=2 '\002', pos=1879496) at /home/pavels/Projects/OpenTTD/src/fileio.cpp:97
#5  0x0000555555cbd4f5 in LoadSpriteV2 (sprite=0x7ffff0f87a60, file_slot=2 '\002', file_pos=1879496, sprite_type=ST_FONT, load_32bpp=true)
    at /home/pavels/Projects/OpenTTD/src/spriteloader/grf.cpp:252
#6  0x0000555555cbd916 in SpriteLoaderGrf::LoadSprite (this=0x7ffff0f87a50, sprite=0x7ffff0f87a60, file_slot=2 '\002', file_pos=1879496, sprite_type=ST_FONT, load_32bpp=true)
    at /home/pavels/Projects/OpenTTD/src/spriteloader/grf.cpp:323
#7  0x0000555555f870a3 in ReadSprite (sc=0x55555b7ee990, id=53, sprite_type=ST_FONT, allocator=0x555555f87d91 <AllocSprite(size_t)>, encoder=0x555558a81390)
    at /home/pavels/Projects/OpenTTD/src/spritecache.cpp:441
#8  0x0000555555f8816c in GetRawSprite (sprite=53, type=ST_FONT, allocator=0x0, encoder=0x0) at /home/pavels/Projects/OpenTTD/src/spritecache.cpp:897
#9  0x0000555555f87ef3 in HandleInvalidSpriteRequest (sprite=53, requested=ST_FONT, sc=0x55555b7ee990, allocator=0x0) at /home/pavels/Projects/OpenTTD/src/spritecache.cpp:841
#10 0x0000555555f8810e in GetRawSprite (sprite=53, type=ST_FONT, allocator=0x0, encoder=0x0) at /home/pavels/Projects/OpenTTD/src/spritecache.cpp:888
#11 0x0000555555d7d087 in GetSprite (sprite=53, type=ST_FONT) at /home/pavels/Projects/OpenTTD/src/spritecache.h:43
#12 0x0000555555d7d937 in SpriteFontCache::GetGlyphWidth (this=0x5555583ed7d0, key=1073741907) at /home/pavels/Projects/OpenTTD/src/fontcache.cpp:193
#13 0x0000555555da22be in FallbackParagraphLayout::FallbackVisualRun::FallbackVisualRun (this=0x7fffbc34f7a0, font=0x7fffbc351780, chars=0x7fffbc3626d0 U"Scanning NewGRFs", 
    char_count=16, x=0) at /home/pavels/Projects/OpenTTD/src/gfx_layout.cpp:346
#14 0x0000555555da8518 in __gnu_cxx::new_allocator<FallbackParagraphLayout::FallbackVisualRun>::construct<FallbackParagraphLayout::FallbackVisualRun, Font*&, char32_t const*&, long, int&> (this=0x7fffbc350298, __p=0x7fffbc34f7a0) at /usr/include/c++/9/ext/new_allocator.h:147
#15 0x0000555555da6712 in std::allocator_traits<std::allocator<FallbackParagraphLayout::FallbackVisualRun> >::construct<FallbackParagraphLayout::FallbackVisualRun, Font*&, char32_t const*&, long, int&> (__a=..., __p=0x7fffbc34f7a0) at /usr/include/c++/9/bits/alloc_traits.h:484
#16 0x0000555555da684b in std::vector<FallbackParagraphLayout::FallbackVisualRun, std::allocator<FallbackParagraphLayout::FallbackVisualRun> >::_M_realloc_insert<Font*&, char32_t const*&, long, int&> (this=0x7fffbc350298, __position=non-dereferenceable iterator for std::vector) at /usr/include/c++/9/bits/vector.tcc:449
#17 0x0000555555da4f74 in std::vector<FallbackParagraphLayout::FallbackVisualRun, std::allocator<FallbackParagraphLayout::FallbackVisualRun> >::emplace_back<Font*&, char32_t const*&, long, int&> (this=0x7fffbc350298) at /usr/include/c++/9/bits/vector.tcc:121
#18 0x0000555555da2c50 in FallbackParagraphLayout::NextLine (this=0x7fffbc350100, max_width=2147483647) at /home/pavels/Projects/OpenTTD/src/gfx_layout.cpp:588
#19 0x0000555555da2e62 in Layouter::Layouter (this=0x7ffff0f87fe0, str=0x7ffff0f88054 "", maxw=2147483647, colour=TC_BEGIN, fontsize=FS_NORMAL)
    at /home/pavels/Projects/OpenTTD/src/gfx_layout.cpp:735
#20 0x0000555555d95af9 in GetStringBoundingBox (str=0x7ffff0f88040 "Scanning NewGRFs", start_fontsize=FS_NORMAL) at /home/pavels/Projects/OpenTTD/src/gfx.cpp:844
#21 0x0000555555d95baf in GetStringBoundingBox (strid=2611) at /home/pavels/Projects/OpenTTD/src/gfx.cpp:859
#22 0x00005555560a0c12 in NWidgetLeaf::SetupSmallestSize (this=0x7fffbc3503d0, w=0x7fffbc3502f0, init_array=true) at /home/pavels/Projects/OpenTTD/src/widget.cpp:2362
#23 0x000055555609cb86 in NWidgetVertical::SetupSmallestSize (this=0x7fffbc07d4e0, w=0x7fffbc3502f0, init_array=true) at /home/pavels/Projects/OpenTTD/src/widget.cpp:1318
#24 0x00005555560a68ec in Window::InitializeData (this=0x7fffbc3502f0, window_number=1) at /home/pavels/Projects/OpenTTD/src/window.cpp:1480
#25 0x00005555560a7a3f in Window::FinishInitNested (this=0x7fffbc3502f0, window_number=1) at /home/pavels/Projects/OpenTTD/src/window.cpp:1850
#26 0x00005555560a7b4d in Window::InitNested (this=0x7fffbc3502f0, window_number=1) at /home/pavels/Projects/OpenTTD/src/window.cpp:1864
#27 0x0000555555ea1fac in ScanProgressWindow::ScanProgressWindow (this=0x7fffbc3502f0) at /home/pavels/Projects/OpenTTD/src/newgrf_gui.cpp:2186
#28 0x0000555555e97e55 in UpdateNewGRFScanStatus (num=478, name=0x7fffbc34fe38 "TIAS 1.7-alpha") at /home/pavels/Projects/OpenTTD/src/newgrf_gui.cpp:2271
#29 0x0000555555e7d94c in GRFFileScanner::AddFile (this=0x7ffff0f88bb0, filename="toei_interconnection_addon_set-1.7alpha/tias.grf", basepath_length=0, 
    tar_filename="/home/pavels/.openttd/content_download/newgrf/54420101-Toei_Inter_connection_Add_on_Se-1.7_al.tar") at /home/pavels/Projects/OpenTTD/src/newgrf_config.cpp:647
#30 0x0000555555d6e0cb in ScanTar (fs=0x7ffff0f88bb0, extension=0x5555564f6249 ".grf", Python Exception <class 'AttributeError'> 'NoneType' object has no attribute 'pointer': 
tar=...) at /home/pavels/Projects/OpenTTD/src/fileio.cpp:1353
#31 0x0000555555d6e280 in FileScanner::Scan (this=0x7ffff0f88bb0, extension=0x5555564f6249 ".grf", sd=NEWGRF_DIR, tars=true, recursive=true)
    at /home/pavels/Projects/OpenTTD/src/fileio.cpp:1385
#32 0x0000555555e7e740 in GRFFileScanner::DoScan () at /home/pavels/Projects/OpenTTD/src/newgrf_config.cpp:596
#33 0x0000555555e7da84 in DoScanNewGRFFiles (callback=0x555558401410) at /home/pavels/Projects/OpenTTD/src/newgrf_config.cpp:685
#34 0x0000555555e7effa in StartNewThread<void (*)(NewGRFScanCallback*), NewGRFScanCallback*>(std::thread*, char const*, void (*&&)(NewGRFScanCallback*), NewGRFScanCallback*&&)::{lambda(char const*, void (*&&)(NewGRFScanCallback*), NewGRFScanCallback*&&)#1}::operator()(char const*, void (*&&)(NewGRFScanCallback*), NewGRFScanCallback*&&) const (this=0x55555b95fbd8, 
    name=0x5555564f6281 "ottd:newgrf-scan", F=@0x55555b95fbe0: 0x555555e7da14 <DoScanNewGRFFiles(NewGRFScanCallback*)>, A#0=@0x55555b95fbd8: 0x555558401410)
    at /home/pavels/Projects/OpenTTD/src/thread.h:56
#35 0x0000555555e83840 in std::__invoke_impl<void, StartNewThread<void (*)(NewGRFScanCallback*), NewGRFScanCallback*>(std::thread*, char const*, void (*&&)(NewGRFScanCallback*), NewGRFS--Type <RET> for more, q to quit, c to continue without paging-- 
canCallback*&&)::{lambda(char const*, void (*&&)(NewGRFScanCallback*), NewGRFScanCallback*&&)#1}, char const*, void (*)(NewGRFScanCallback*), NewGRFScanCallback*>(std::__invoke_other, StartNewThread<void (*)(NewGRFScanCallback*), NewGRFScanCallback*>(std::thread*, char const*, void (*&&)(NewGRFScanCallback*), NewGRFScanCallback*&&)::{lambda(char const*, void (*&&&&)(NewGRFScanCallback*), NewGRFScanCallback*&&)#1}, char const*&&, void (*&&)(NewGRFScanCallback*), NewGRFScanCallback*&&) (__f=...) at /usr/include/c++/9/bits/invoke.h:60
#36 0x0000555555e83718 in std::__invoke<StartNewThread<void (*)(NewGRFScanCallback*), NewGRFScanCallback*>(std::thread*, char const*, void (*&&)(NewGRFScanCallback*), NewGRFScanCallback*&&)::{lambda(char const*, void (*&&)(NewGRFScanCallback*), NewGRFScanCallback*&&)#1}, char const*, void (*)(NewGRFScanCallback*), NewGRFScanCallback*> (__fn=...)
    at /usr/include/c++/9/bits/invoke.h:95
#37 0x0000555555e835f7 in std::thread::_Invoker<std::tuple<StartNewThread<void (*)(NewGRFScanCallback*), NewGRFScanCallback*>(std::thread*, char const*, void (*&&)(NewGRFScanCallback*), NewGRFScanCallback*&&)::{lambda(char const*, void (*&&)(NewGRFScanCallback*), NewGRFScanCallback*&&)#1}, char const*, void (*)(NewGRFScanCallback*), NewGRFScanCallback*> >::_M_invoke<0ul, 1ul, 2ul, 3ul>(std::_Index_tuple<0ul, 1ul, 2ul, 3ul>) (this=0x55555b95fbd8) at /usr/include/c++/9/thread:244
#38 0x0000555555e83576 in std::thread::_Invoker<std::tuple<StartNewThread<void (*)(NewGRFScanCallback*), NewGRFScanCallback*>(std::thread*, char const*, void (*&&)(NewGRFScanCallback*), NewGRFScanCallback*&&)::{lambda(char const*, void (*&&)(NewGRFScanCallback*), NewGRFScanCallback*&&)#1}, char const*, void (*)(NewGRFScanCallback*), NewGRFScanCallback*> >::operator()() (this=0x55555b95fbd8) at /usr/include/c++/9/thread:251
#39 0x0000555555e83556 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<StartNewThread<void (*)(NewGRFScanCallback*), NewGRFScanCallback*>(std::thread*, char const*, void (*&&)(NewGRFScanCallback*), NewGRFScanCallback*&&)::{lambda(char const*, void (*&&)(NewGRFScanCallback*), NewGRFScanCallback*&&)#1}, char const*, void (*)(NewGRFScanCallback*), NewGRFScanCallback*> > >::_M_run() (this=0x55555b95fbd0) at /usr/include/c++/9/thread:195
#40 0x00007ffff7680d84 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#41 0x00007ffff7794609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#42 0x00007ffff736e293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Steps to reproduce

  1. Download everything from bananas ;)
  2. Start the game
  3. Quickly close the window before newgrf scan finishes
JGRennison added a commit to JGRennison/OpenTTD-patches that referenced this issue Mar 1, 2021
@JGRennison
Copy link
Contributor

@JGRennison JGRennison commented Mar 1, 2021

JGRennison/OpenTTD-patches@0a31a3b fixes the issue in my branch. This could provide a starting point for a fix here.

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

Successfully merging a pull request may close this issue.

3 participants