CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.33k stars 4.14k forks source link

Game crash during an autosave #33051

Closed ghost closed 5 years ago

ghost commented 5 years ago

Describe the bug

The game crashed while autosaving Looks like it saved everything except the motorbike I was riding

Edit: The motorbike actually warped back to the refugee center entrance and got reset to a state it was in during previous autosave (gasoline amount, items in cargo hold). Same goes for the Free Merchants' cars that I sucked gasoline from

Expected behavior

No crash

Versions and configuration

Additional context

crash.log debug.log Powder Springs - corrupted.zip

ZhilkinSerg commented 5 years ago

Possible related to #33046

EvgenijM86 commented 5 years ago

This have happened to me 2 times at least, in the builds from last 16 hours.

EvgenijM86 commented 5 years ago

It can also crash during autosaves when you try to sleep.

sztosz commented 5 years ago

I had numerous saving segfaults today too. It's VERSION: 0.D-6376-gd7dc3df419, details below.

The program has crashed.
See the log file for a stack trace.
CRASH LOG FILE: ./config/crash.log
VERSION: 0.D-6376-gd7dc3df419
TYPE: Signal
MESSAGE: SIGSEGV: Segmentation fault
STACK TRACE:

    ./cataclysm-tiles(_Z21debug_write_backtraceRSo+0x39) [0x558ca98d3c19]
    ./cataclysm-tiles(+0x606014) [0x558ca98b1014]
    ./cataclysm-tiles(+0x605b28) [0x558ca98b0b28]
    /usr/lib/libc.so.6(+0x3a7e0) [0x7f58fa4297e0]
    ./cataclysm-tiles(_ZNK7monster5storeER7JsonOut+0x172c) [0x558caa5c4eac]
    ./cataclysm-tiles(_ZNK7overmap9serializeERSo+0x1be4) [0x558caa581474]
    ./cataclysm-tiles(_ZNK7overmap4saveEv+0x110) [0x558caa36fe60]
    ./cataclysm-tiles(_ZN4game9save_mapsEv+0x41) [0x558ca9a3f3f1]
    ./cataclysm-tiles(_ZN4game4saveEv+0x4f) [0x558ca9a5de1f]
    ./cataclysm-tiles(_ZN4game9quicksaveEv+0xf5) [0x558ca9a5dd65]
    ./cataclysm-tiles(_ZN4game13handle_actionEv+0x3a9b) [0x558ca9b291ab]
    ./cataclysm-tiles(_ZN4game7do_turnEv+0xf08) [0x558ca9a48e38]
    ./cataclysm-tiles(main+0x188c) [0x558ca9e65b5c]
    /usr/lib/libc.so.6(__libc_start_main+0xf3) [0x7f58fa415ee3]
    ./cataclysm-tiles(_start+0x2e) [0x558ca95b8bee]

    Attempting to repeat stack trace using debug symbols...
    debug_write_backtrace(std::ostream&)
    ??:?
    log_crash(char const*, char const*)
    ld-temp.o:?
    signal_handler(int)
    ld-temp.o:?
    ??
    ??:0
    monster::store(JsonOut&) const
    ??:?
    overmap::serialize(std::ostream&) const
    ??:?
    overmap::save() const
    ??:?
    game::save_maps()
    ??:?
    game::save()
    ??:?
    game::quicksave()
    ??:?
    game::handle_action()
    ??:?
    game::do_turn()
    ??:?
    main
    ??:?
    __libc_start_main
    ??:?
    _start
    ??:?
- OS: Linux
    - OS Version: <unknown>
- Game Version: 0.D-6376-gd7dc3df419 [64-bit]
- Graphics Version: Tiles
- Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food],
    Alternative Map Key [alt_map_key],
    Beta National Guard Camp [national_guard_camp],
    Urban Development [Urban_Development],
    sees-player icon, +attitude [sees_player],
    Disable Religious Texts [no_religious_Texts],
    No Antique Firearms [no_olg_guns],
    No Flaming Weapons [no_flaming_weapons],
    No Ants [No_Anthills],
    No Fungal Monsters [No_Fungi],
    Prevent Zombie Revivication [no_reviving_zombies],
    Safe Autodoc [safeautodoc],
    Simplified Nutrition [novitamins]
]
r3mowilliams commented 5 years ago

Experienced lots of autosave segfaulting with 0.D-6301 and the world state being slightly 'reset'

New game, very minimal mods. Rolling back to 0.D-6277 stopped the autosave segfaulting.

ZhilkinSerg commented 5 years ago

Experienced lots of autosave segfaulting with 0.D-6301 and the world state being slightly 'reset'

New game, very minimal mods. Rolling back to 0.D-6277 stopped the autosave segfaulting.

Can you give full version numbers?

r3mowilliams commented 5 years ago

Can you give full version numbers?

Sure. 0.D-6301-g3597e0ffa8 0.D-6277-g87276a7

ZhilkinSerg commented 5 years ago

Thanks. Builds 9449 and 9446 then.

ZhilkinSerg commented 5 years ago

Possible cause is https://github.com/CleverRaven/Cataclysm-DDA/pull/32996.

anothersimulacrum commented 5 years ago

Confirmed, here's a stack trace with debug symbols from d7dc3df4191b589c9fcbc0f26219296eca8b8624 (no mods)

32996 Looks very likely as the cause.

Attempting to repeat stack trace using debug symbols... debug_write_backtrace(std::ostream&) .../src/debug.cpp:621 std::cxx11::basic_ostringstream<char, std::char_traits, std::allocator >::str() const /usr/include/c++/9.1.0/sstream:678 log_crash .../src/crash.cpp:263 signal_handler .../src/crash.cpp:292 ?? ??:0 player::getID() const .../src/player.cpp:10706 monster::store(JsonOut&) const .../src/savegame_json.cpp:1893 monster::serialize(JsonOut&) const .../src/savegame_json.cpp:1843 std::detail::_Node_iterator_base<std::pair<tripoint const, monster>, true>::_M_incr() /usr/include/c++/9.1.0/bits/hashtable_policy.h:299 std::detail::_Node_const_iterator<std::pair<tripoint const, monster>, false, true>::operator++() /usr/include/c++/9.1.0/bits/hashtable_policy.h:406 overmap::serialize(std::ostream&) const .../src/savegame.cpp:1353 write_to_file(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::function<void (std::ostream&)> const&) .../src/cata_utility.cpp:334 std::cxx11::basic_string<char, std::char_traits, std::allocator >::~basic_string() /usr/include/c++/9.1.0/bits/basic_string.h:658 overmap::save() const .../src/overmap.cpp:4238 std::detail::_Node_iterator_base<std::pair<point const, std::unique_ptr<overmap, std::default_delete > >, true>::_M_incr() /usr/include/c++/9.1.0/bits/hashtable_policy.h:299 (discriminator 2) std::__detail::_Node_iterator<std::pair<point const, std::unique_ptr<overmap, std::default_delete > >, false, true>::operator++() /usr/include/c++/9.1.0/bits/hashtable_policy.h:354 (discriminator 2) overmapbuffer::save() .../src/overmapbuffer.cpp:201 (discriminator 2) game::save_maps() .../src/game.cpp:2846 game::save() .../src/game.cpp:2889 game::quicksave() .../src/game.cpp:11181 game::quicksave() .../src/game.cpp:11166 game::autosave() .../src/game.cpp:11213 game::do_turn() .../src/game.cpp:1424 main .../src/main.cpp:688 __libc_start_main ??:? _start ??:?

crazykiddeath commented 5 years ago

I dunno if this will help but here is a copy of my crash log too:

CRASH LOG FILE: config/crash.log
VERSION: 0.D-6411-g2493ae5
TYPE: Signal
MESSAGE: SIGSEGV: Segmentation fault
STACK TRACE:
    @0x59E915[cataclysm-tiles.exe+0x19E915]
    @0x59F3E2[cataclysm-tiles.exe+0x19F3E2]
    SMPEG_error+0x4B034@0xF30150[cataclysm-tiles.exe+0xB30150]
    _C_specific_handler+0x98@0x7FFEAFD78048[msvcrt.dll+0x28048]
    _chkstk+0x11F@0x7FFEB198119F[ntdll.dll+0xA119F]
    RtlRaiseException+0x399@0x7FFEB194A229[ntdll.dll+0x6A229]
    KiUserExceptionDispatcher+0x2E@0x7FFEB197FE0E[ntdll.dll+0x9FE0E]
    @0xC16800[cataclysm-tiles.exe+0x816800]
    @0xD10415[cataclysm-tiles.exe+0x910415]
    @0xD10591[cataclysm-tiles.exe+0x910591]
    IMG_LoadWEBP_RW+0x2D451D@0x12F64DD[cataclysm-tiles.exe+0xEF64DD]
    @0xCFB8C8[cataclysm-tiles.exe+0x8FB8C8]
    @0xCFBEAF[cataclysm-tiles.exe+0x8FBEAF]
    @0x4FCDE6[cataclysm-tiles.exe+0xFCDE6]
    @0xB83F6D[cataclysm-tiles.exe+0x783F6D]
    @0xBC2E79[cataclysm-tiles.exe+0x7C2E79]
    @0x680D5A[cataclysm-tiles.exe+0x280D5A]
    @0x680E20[cataclysm-tiles.exe+0x280E20]
    @0x6811F6[cataclysm-tiles.exe+0x2811F6]
    @0x6DFDB2[cataclysm-tiles.exe+0x2DFDB2]
    @0x6BB637[cataclysm-tiles.exe+0x2BB637]
    IMG_LoadWEBP_RW+0x59A498@0x15BC458[cataclysm-tiles.exe+0x11BC458]
    @0x4013ED[cataclysm-tiles.exe+0x13ED]
    @0x4014FB[cataclysm-tiles.exe+0x14FB]
    BaseThreadInitThunk+0x14@0x7FFEB0757BD4[KERNEL32.DLL+0x17BD4]
    RtlUserThreadStart+0x21@0x7FFEB194CE71[ntdll.dll+0x6CE71]
VReaperV commented 5 years ago

Happens on Android on build-9468 as well:

[08-11 12:46:27.258 7271:7271 F/DEBUG]
pid: 7152, tid: 7193, name: SDLThread  >>> com.cleverraven.cataclysmdda <<<
[08-11 12:46:27.277 7271:7271 F/DEBUG]
#00 pc 00bfd710  /data/app/com.cleverraven.cataclysmdda-2/lib/arm/libmain.so (_ZNK6player5getIDEv+3)
[08-11 12:46:27.277 7271:7271 F/DEBUG]
#01 pc 00c9ae9f  /data/app/com.cleverraven.cataclysmdda-2/lib/arm/libmain.so (_ZNK7monster5storeER7JsonOut+2618)
[08-11 12:46:27.277 7271:7271 F/DEBUG]
#02 pc 00c9a455  /data/app/com.cleverraven.cataclysmdda-2/lib/arm/libmain.so (_ZNK7monster9serializeER7JsonOut+20)
[08-11 12:46:27.277 7271:7271 F/DEBUG]
#03 pc 00c89533  /data/app/com.cleverraven.cataclysmdda-2/lib/arm/libmain.so (_ZNK7overmap9serializeERNSt6__ndk113basic_ostreamIcNS0_11char_traitsIcEEEE+1882)
[08-11 12:46:27.278 7271:7271 F/DEBUG]
#04 pc 0066ebf1  /data/app/com.cleverraven.cataclysmdda-2/lib/arm/libmain.so (_Z13write_to_fileRKNSt6__ndk112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEERKNS_8functionIFvRNS_13basic_ostreamIcS2_EEEEE+24)
[08-11 12:46:27.278 7271:7271 F/DEBUG]
#05 pc 00b8e48d  /data/app/com.cleverraven.cataclysmdda-2/lib/arm/libmain.so (_ZNK7overmap4saveEv+112)
[08-11 12:46:27.278 7271:7271 F/DEBUG]
#06 pc 00b6cd51  /data/app/com.cleverraven.cataclysmdda-2/lib/arm/libmain.so (_ZN13overmapbuffer4saveEv+10)
[08-11 12:46:27.278 7271:7271 F/DEBUG]
#07 pc 00791eab  /data/app/com.cleverraven.cataclysmdda-2/lib/arm/libmain.so (_ZN4game9save_mapsEv+18)
[08-11 12:46:27.278 7271:7271 F/DEBUG]
#08 pc 0079fb7d  /data/app/com.cleverraven.cataclysmdda-2/lib/arm/libmain.so (_ZN4game4saveEv+48)
[08-11 12:46:27.278 7271:7271 F/DEBUG]
#09 pc 007c1c0b  /data/app/com.cleverraven.cataclysmdda-2/lib/arm/libmain.so (_ZN4game9quicksaveEv+118)
[08-11 12:46:27.278 7271:7271 F/DEBUG]
#10 pc 007ed3d1  /data/app/com.cleverraven.cataclysmdda-2/lib/arm/libmain.so (_ZN4game13handle_actionEv+6096)
[08-11 12:46:27.278 7271:7271 F/DEBUG]
#11 pc 00793483  /data/app/com.cleverraven.cataclysmdda-2/lib/arm/libmain.so (_ZN4game7do_turnEv+1202)
[08-11 12:46:27.278 7271:7271 F/DEBUG]
#12 pc 009627d1  /data/app/com.cleverraven.cataclysmdda-2/lib/arm/libmain.so (SDL_main+3632)
[08-11 12:46:27.278 7271:7271 F/DEBUG]
#13 pc 000250c9  /data/app/com.cleverraven.cataclysmdda-2/lib/arm/libSDL2.so (Java_org_libsdl_app_SDLActivity_nativeRunMain+352)
[08-11 12:46:27.279 7271:7271 F/DEBUG]
#14 pc 000107c5  /data/app/com.cleverraven.cataclysmdda-2/oat/arm/base.odex (offset 0x10000)
[08-11 12:46:28.357 1857:7272 W/ActivityManager]
Force finishing activity com.cleverraven.cataclysmdda/.CataclysmDDA
EvgenijM86 commented 5 years ago

This has fixed it for me: git revert 694fcea0537b34e31045912ac09d8db7ba33d707

VReaperV commented 5 years ago

Confirmed, here's a stack trace with debug symbols from d7dc3df (no mods)

32996 Looks very likely as the cause.

Attempting to repeat stack trace using debug symbols... debug_write_backtrace(std::ostream&) .../src/debug.cpp:621 std::cxx11::basic_ostringstream<char, std::char_traits, std::allocator >::str() const /usr/include/c++/9.1.0/sstream:678 log_crash .../src/crash.cpp:263 signal_handler .../src/crash.cpp:292 ?? ??:0 player::getID() const .../src/player.cpp:10706 monster::store(JsonOut&) const .../src/savegame_json.cpp:1893 monster::serialize(JsonOut&) const .../src/savegame_json.cpp:1843 std::detail::_Node_iterator_base<std::pair<tripoint const, monster>, true>::_M_incr() /usr/include/c++/9.1.0/bits/hashtable_policy.h:299 std::detail::_Node_const_iterator<std::pair<tripoint const, monster>, false, true>::operator++() /usr/include/c++/9.1.0/bits/hashtable_policy.h:406 overmap::serialize(std::ostream&) const .../src/savegame.cpp:1353 write_to_file(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::function<void (std::ostream&)> const&) .../src/cata_utility.cpp:334 std::cxx11::basic_string<char, std::char_traits, std::allocator >::~basic_string() /usr/include/c++/9.1.0/bits/basic_string.h:658 overmap::save() const .../src/overmap.cpp:4238 std::detail::_Node_iterator_base<std::pair<point const, std::unique_ptr<overmap, std::default_delete > >, true>::_M_incr() /usr/include/c++/9.1.0/bits/hashtable_policy.h:299 (discriminator 2) std::__detail::_Node_iterator<std::pair<point const, std::unique_ptr<overmap, std::default_delete > >, false, true>::operator++() /usr/include/c++/9.1.0/bits/hashtable_policy.h:354 (discriminator 2) overmapbuffer::save() .../src/overmapbuffer.cpp:201 (discriminator 2) game::save_maps() .../src/game.cpp:2846 game::save() .../src/game.cpp:2889 game::quicksave() .../src/game.cpp:11181 game::quicksave() .../src/game.cpp:11166 game::autosave() .../src/game.cpp:11213 game::do_turn() .../src/game.cpp:1424 main .../src/main.cpp:688 __libc_start_main ??:? _start ??:?

I thought this might happen because savegame_json.cpp sets dragged_foe_id and assigns dragged_foe with nullptr, and then it doesn't get updated with the actual pointer, but this has also happened to me when I Quick-Saved after waiting for 1 turn in a new world.

Lord-Helmchen commented 5 years ago

probably the same thing that is happening to me. Crash during autosave, can load the game but I've just lost my third shopping cart with most of my food and equipment. image

pjf commented 5 years ago

Just a quick note that I've written a fix for this and am currently testing it. With luck it'll become a PR later today.

Lord-Helmchen commented 5 years ago

sadly, not for me: image

Grand Junction.zip

anothersimulacrum commented 5 years ago

I couldn't reproduce it (on a later version fffed0be4b064fcddf1c176978aa847952046ed9). Though because this is after the fix, could you make a separate issue?

VReaperV commented 5 years ago

sadly, not for me: image

Grand Junction.zip

Works fine for me (on 9479).

ZhilkinSerg commented 5 years ago

That was build before the fix.

anothersimulacrum commented 5 years ago

The commit hash indicates it was from 38912d401c57bf8a913a6acb4c0ad4e281779cb2, which is after the commit which fixes this bug ( 4a878ffb8a2ce27b98df25a8ef18d75534652aac ).

ZhilkinSerg commented 5 years ago
#9477 (Aug 12, 2019 8:28:24 PM)

    Apply extra care with monster dragging code to avoid segfaults (commit: 4a878ff) — pjf / githubweb
    Enable bugprone-too-small-loop-variable (commit: 9d72a63) — jbytheway / githubweb
    Enable cert-dcl59-cpp (commit: aeb643f) — jbytheway / githubweb
    Add custom clang-tidy check to improve use of point arithmetic operators (commit: 6c8f543) — ZhilkinSerg / githubweb

#9476 (Aug 12, 2019 5:12:34 PM)

    Lower chainsaw fuel consumption (commit: 2c80a55) — ampersand555555 / githubweb
    Translated Russian MOTD (commit: f4fc807) — Night_Pryanik / githubweb
    unstranslated strng (commit: ab80c12) — sthapplz / githubweb
    Apply suggestions from code review (commit: 3ed53cd) — github / githubweb
    Firing menu i18n fix (#33159) (commit: 38912d4) — ZhilkinSerg / githubweb
anothersimulacrum commented 5 years ago

Huh, I guess the commits page was lying (or, more likely, I read it wrong). Sorry for the confusion.

ZhilkinSerg commented 5 years ago

It is possible that initial commit dates are different from date of merge commit.

Lord-Helmchen commented 5 years ago

I'm embarrassed to notice I apparently managed to update after reading this was merged but before it was actually integrated in the build... I apologize for the inconvenience.