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 crash during an autosave #33051

Closed
antipin00 opened this issue Aug 8, 2019 · 25 comments

Comments

@antipin00
Copy link

commented Aug 8, 2019

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

  • OS: Windows
    • OS Version: 10.0 1809
  • Game Version: 0.D-6301-g3597e0f [64-bit]
  • Graphics Version: Tiles
  • Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food],
    Icecoon's Arsenal [ew_pack],
    Makeshift Items Mod [makeshift],
    More Survival Tools [More_Survival_Tools],
    Modular Turrets [modular_turrets],
    Salvaged Robots [Salvaged_Robots],
    Alternative Map Key [alt_map_key],
    Hydroponics [hydroponics],
    Mutant NPCs [mutant_npcs],
    More Locations [more_locations],
    Fuji's More Buildings [FujiStruct],
    Folding Parts pack [deoxymod],
    Vehicle Additions Pack [blazemod],
    Tanks and Other Vehicles [Tanks],
    No Fungal Monsters [No_Fungi],
    Safe Autodoc [safeautodoc],
    Simplified Nutrition [novitamins],
    StatsThroughSkills [StatsThroughSkills]
    ]

Additional context

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

@ZhilkinSerg

This comment has been minimized.

Copy link
Contributor

commented Aug 8, 2019

Possible related to #33046

@EvgenijM86

This comment has been minimized.

Copy link

commented Aug 8, 2019

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

@EvgenijM86

This comment has been minimized.

Copy link

commented Aug 9, 2019

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

@sztosz

This comment has been minimized.

Copy link
Contributor

commented Aug 9, 2019

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

This comment has been minimized.

Copy link

commented Aug 9, 2019

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

This comment has been minimized.

Copy link
Contributor

commented Aug 9, 2019

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

This comment has been minimized.

Copy link

commented Aug 9, 2019

Can you give full version numbers?

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

@ZhilkinSerg

This comment has been minimized.

Copy link
Contributor

commented Aug 9, 2019

Thanks. Builds 9449 and 9446 then.

@ZhilkinSerg

This comment has been minimized.

Copy link
Contributor

commented Aug 9, 2019

Possible cause is #32996.

@anothersimulacrum

This comment has been minimized.

Copy link
Contributor

commented Aug 9, 2019

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
??:?

@crazykiddeath

This comment has been minimized.

Copy link

commented Aug 10, 2019

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]

@Reaper9

This comment has been minimized.

Copy link

commented Aug 11, 2019

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

This comment has been minimized.

Copy link

commented Aug 11, 2019

This has fixed it for me:
git revert 694fcea0537b34e31045912ac09d8db7ba33d707

@Reaper9

This comment has been minimized.

Copy link

commented Aug 11, 2019

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

This comment has been minimized.

Copy link

commented Aug 11, 2019

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

This comment has been minimized.

Copy link
Contributor

commented Aug 11, 2019

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.

pjf added a commit to pjf/Cataclysm-DDA that referenced this issue Aug 11, 2019

Apply extra care with monster dragging code to avoid segfaults
Based upon my interpretation of the stack-trace in CleverRaven#33104, it appears
that `monster::store` is trying to use a dragged_foe that's not null,
but is no longer valid, either. This may happen if the foe is dead, or
any other condition that may cause the dragged critter object to be destroyed.

This commit:

- Always tracks the `dragged_foe_id` (an integer) rather than
  `dragged_foe` (a pointer) directly.
- Uses `critter_by_id()` to check the validity of the `dragged_foe_id`
  on the occasions when it needed. This is the same function used by the
  savegame loading code to restore the dragged foe.
- Moves the dragged_foe-finding functionality to its own method for
  clarity.
- Ensures the dragged_foe-finding code clears relevant status effects
  and members if we're no longer dragging a valid critter.
- Moves the nursebot operation code to its own method, also for clarity.

Note that I don't have a reproducable way to induce the bug, so I don't
have a great test for this. However it's hard to have a segfault if you
don't have a stale pointer to deference in the first place.

Fixes CleverRaven#33051. Fixes CleverRaven#33141.

pjf added a commit to pjf/Cataclysm-DDA that referenced this issue Aug 12, 2019

Apply extra care with monster dragging code to avoid segfaults
Based upon my interpretation of the stack-trace in CleverRaven#33104, it appears
that `monster::store` is trying to use a dragged_foe that's not null,
but is no longer valid, either. This may happen if the foe is dead, or
any other condition that may cause the dragged critter object to be destroyed.

This commit:

- Always tracks the `dragged_foe_id` (an integer) rather than
  `dragged_foe` (a pointer) directly.
- Uses `critter_by_id()` to check the validity of the `dragged_foe_id`
  on the occasions when it needed. This is the same function used by the
  savegame loading code to restore the dragged foe.
- Moves the dragged_foe-finding functionality to its own method for
  clarity.
- Ensures the dragged_foe-finding code clears relevant status effects
  and members if we're no longer dragging a valid critter.
- Moves the nursebot operation code to its own method, also for clarity.

Note that I don't have a reproducable way to induce the bug, so I don't
have a great test for this. However it's hard to have a segfault if you
don't have a stale pointer to deference in the first place.

Fixes CleverRaven#33051. Fixes CleverRaven#33141.
@Lord-Helmchen

This comment has been minimized.

Copy link

commented Aug 12, 2019

sadly, not for me:
image

Grand Junction.zip

@anothersimulacrum

This comment has been minimized.

Copy link
Contributor

commented Aug 13, 2019

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

@Reaper9

This comment has been minimized.

Copy link

commented Aug 13, 2019

sadly, not for me:
image

Grand Junction.zip

Works fine for me (on 9479).

@ZhilkinSerg

This comment has been minimized.

Copy link
Contributor

commented Aug 13, 2019

That was build before the fix.

@anothersimulacrum

This comment has been minimized.

Copy link
Contributor

commented Aug 13, 2019

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

@ZhilkinSerg

This comment has been minimized.

Copy link
Contributor

commented Aug 13, 2019

#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

This comment has been minimized.

Copy link
Contributor

commented Aug 13, 2019

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

@ZhilkinSerg

This comment has been minimized.

Copy link
Contributor

commented Aug 13, 2019

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

@Lord-Helmchen

This comment has been minimized.

Copy link

commented Aug 13, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
10 participants
You can’t perform that action at this time.