CleverRaven / Cataclysm-DDA

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

Deconstructing crashes in Single_item_creator::every_item_min_max #75073

Closed l29ah closed 4 weeks ago

l29ah commented 1 month ago

Describe the bug

#0  0x00007f94324c505c in __pthread_kill_implementation () from /lib64/libc.so.6
#1  0x00007f94324752b6 in raise () from /lib64/libc.so.6
#2  0x00007f943245d8b7 in abort () from /lib64/libc.so.6
#3  0x000056233eea7e6e in signal_handler (sig=<optimized out>) at src/crash.cpp:154
#4  <signal handler called>
#5  0x00007f94324c505c in __pthread_kill_implementation () from /lib64/libc.so.6
#6  0x00007f94324752b6 in raise () from /lib64/libc.so.6
#7  0x00007f943245d8b7 in abort () from /lib64/libc.so.6
#8  0x00007f94326dab8f in std::__glibcxx_assert_fail (file=file@entry=0x562340734900 "/usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13/optional", line=line@entry=486, 
    function=function@entry=0x5623407b8ce0 "constexpr const _Tp& std::_Optional_base_impl<_Tp, _Dp>::_M_get() const [with _Tp = Item_modifier; _Dp = std::_Optional_base<Item_modifier, false, false>]", 
    condition=condition@entry=0x5623406e6759 "this->_M_is_engaged()") at /var/tmp/portage/sys-devel/gcc-14.1.1_p20240622/work/gcc-14-20240622/libstdc++-v3/src/c++11/assert_fail.cc:41
#9  0x000056233f58e58f in std::_Optional_base_impl<Item_modifier, std::_Optional_base<Item_modifier, false, false> >::_M_get (this=<optimized out>) at /usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13/optional:484
#10 std::_Optional_base_impl<Item_modifier, std::_Optional_base<Item_modifier, false, false> >::_M_get (this=<optimized out>) at /usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13/optional:484
#11 std::optional<Item_modifier>::operator-> (this=<optimized out>) at /usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13/optional:964
#12 Single_item_creator::every_item_min_max (this=0x562351b845a0) at src/item_group.cpp:498
#13 0x000056233f58a83e in Item_group::every_item_min_max (this=<optimized out>) at src/item_group.cpp:1013
#14 0x000056233edea886 in operator() (drop_group=..., __closure=<optimized out>) at src/construction.cpp:2048
#15 0x000056233edeb393 in construct::do_turn_deconstruct (p=..., who=...) at src/construction.cpp:2071
#16 0x000056233e993984 in activity_handlers::build_do_turn (act=0x56235047ae38, you=0x56235047a770) at src/activity_handlers.cpp:3417
#17 0x000056233e9f4c43 in std::function<void(player_activity*, Character*)>::operator() (__args#1=<optimized out>, __args#0=<optimized out>, this=<optimized out>)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13/bits/std_function.h:591
#18 activity_type::call_do_turn (this=<optimized out>, act=act@entry=0x56235047ae38, you=you@entry=0x56235047a770) at src/activity_type.cpp:159
#19 0x0000562340006726 in player_activity::do_turn (this=0x56235047ae38, you=...) at src/player_activity.cpp:320
#20 0x000056233efee62f in do_turn () at src/do_turn.cpp:592
#21 0x000056233e70dc4d in main (argc=<optimized out>, argv=<optimized out>) at src/main.cpp:873

Attach save file

2024.07.14.zip

Steps to reproduce

Expected behavior

No crashing.

Screenshots

Versions and configuration

Additional context

No response

PatrikLundell commented 1 month ago

Failed to repeat it with master as of an hour or two ago. Disassembly of the thing resulted in a pile of stuff. I'm on Windows and using tiles, so either of those may factor into it.

l29ah commented 1 month ago

Failed to repeat it with master as of an hour or two ago. Disassembly of the thing resulted in a pile of stuff. I'm on Windows and using tiles, so either of those may factor into it.

Or you built it without assertions, or with a less hardened std implementation, so it's a silent uninitialized memory read instead.

PatrikLundell commented 1 month ago

I use whatever they decided to use for Windows release builds. If the version for your OS has different settings, you're using debug builds, or have made your own tweaks, yes, that may well result in errors you get not getting caught on my system.

inogenous commented 1 month ago

I believe this is fixed by #75325 . I am able to reliably reproduce this crash using hardened CXXFLAGS, but if the changes from #75325 are applied, it no longer crashes.

GuardianDll commented 4 weeks ago

If someone reproduce it again on recent experimental, please ping me