Where to start if seeing Segfaults? Experimental, Linux 0.C-19952-g3d4a0eb

I hate to make a new thread for anything, but I wasn’t sure what else would be relevant. How should I proceed if about four days ago I compiled the experimental on Ubuntu 16.04.1 LTS, made a bunch of progress (really I’m killing it compared to any game I’ve ever had, although it’s only day 3 in-game, I’m in a really good position). So I get segfaults pretty often but randomlyish, but very often near my base which now has a ton of items. Imagine about 5 or more carts full of items. The segfaults only started on day three when I got all of these items to my base

My system is x86_64 with tons of ram

I compiled it myself with (I do have ccache set up but this was the first compilation of cdda on this system)
make -j4 CCACHE=1 RELEASE=1 TILES=1 LUA=1

Is there anything I can do to determine what the exact problem is? I hope this isn’t too annoying to just pop in as a noob and make this thread. I LOVE this game, I’ve been playing it for over a year and a half but never really trying to actually make it to mid-game, well, I’m trying now. The game has changed a fair bit over time but I’ve never experienced many segfaults like I am right now. Should I just save and backup saves a lot and press through?

(It says I’m not allowed to post external links?)
Edit: It didn’t like the Code markup or whatever for some reason

I’ll have to see if I can figure out which mods I used for the world generation. Not many, I’ll post back tomorrow about that

On Linux, the best way is to compile a debug build and “gdb -ex run ./cataclysm”

If that is too slow for you or fails to reproduce the errors, you can build a release build with debug symbols by adding DEBUG_SYMBOLS=1 to the make line. Then run gdb as above.

When the segfault triggers, “bt” will give you the backtrace. Backtraces are almost always useful for bugfixing.
There are gdb tutorials available. It’s usually a good idea to print some of the variables on the topmost frame, sometimes on the few frames below.

Thank you Coolthultu!

I did recompile with symbols, and have been running with GDB. I’m no programmer but watched a few decent tutorials GDB and did the backtrace and poked around. It’s always (except one time) caused by walking onto the same tile as a shopping cart. The backtraces have some similarities, the first five # or so are relating to some C++ libraries outside of CDDA (this varies a bit, some have one level more than others), then it inevitably goes to

#6 0x00000000005c3663 in vpart_info::has_flag (this=<optimized out>, flag="REACTOR") at src/veh_type.h:205

None of this means very much to me but I looked at all of the referenced source code files in CDDA and then looked at the large number of open bugs on the github and decided I can prevent this most of the time by simply not stepping on a shopping cart, and keeping them away when I’m not using them. Probably not worthwhile to add another bug report that can be worked around. Just curious though, does that "flag=“REACTOR” have something to do with a vehicle having an installed reactor? Shopping carts (at least mine) don’t have a bleeping reactor!

I really wish I could contribute to this game but I would have a long long way to go before I could be useful with coding, which seems like where nearly all of the work would be

And now I’m surfing the cdda subreddit and found this link which shows recent changes for reactors

http://ci.narc.ro/view/Cataclysm-DDA/job/Cataclysm-Matrix/changes


(among others)

I don’t know exactly how to read the versions of experimental like in my thread subject (0.C-19952-g3d4a0eb) but when I recompiled with symbols I did another git clone first and got (0.C-20042-g8c3bc14).

So considering there have been active changes regarding reactors, I kind of think it has something to do with that. I guess the risk of using experimental. I should probably compile again considering there were further commits regarding reactors

Here are two backtraces

[code]Thread 1 “cataclysm-tiles” received signal SIGSEGV, Segmentation fault.
0x00007ffff7201256 in std::__cxx11::basic_string<char, std::char_traits, std::allocator >::compare(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) const ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(gdb) bt
#0 0x00007ffff7201256 in std::__cxx11::basic_string<char, std::char_traits, std::allocator >::compare(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) const ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#1 0x0000000000433142 in std::operator< <char, std::char_traits, std::allocator > (
__lhs=<error reading variable: Cannot access memory at address 0x77206e6f69746996>, __rhs=“REACTOR”) at /usr/include/c++/5/bits/basic_string.h:4989
#2 0x0000000000487392 in std::less<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >::operator() (this=,
__y=“REACTOR”, __x=…) at /usr/include/c++/5/bits/stl_function.h:387
#3 std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::_Identity<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >, std::less<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits, std::allocator > > >::_M_lower_bound (this=, __k=“REACTOR”, __y=0xe8d4218, __x=)
at /usr/include/c++/5/bits/stl_tree.h:1644
#4 std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::_Identity<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >, std::less<std::__cxx11::basic_string<char,—Type to continue, or q to quit—
std::char_traits, std::allocator > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits, std::allocator > > >::find (
__k=“REACTOR”, this=0xe8d4210) at /usr/include/c++/5/bits/stl_tree.h:2308
#5 std::set<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::less<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits, std::allocator > > >::count (this=0xe8d4210,
__x=“REACTOR”) at /usr/include/c++/5/bits/stl_set.h:668
#6 0x00000000005c3663 in vpart_info::has_flag (this=,
flag=“REACTOR”) at src/veh_type.h:205
#7 0x000000000072e458 in vehicle_part::is_reactor (this=this@entry=
0xe329c0 vehicle::current_engine()::null_part) at src/vehicle.cpp:6116
#8 0x000000000072e546 in vehicle_part::ammo_currentabi:cxx11 const (
this=this@entry=0xe329c0 vehicle::current_engine()::null_part)
at src/vehicle.cpp:5844
#9 0x00000000007cc1b2 in player::disp_status (this=0xdcc2580, w=0xd095520,
w2=) at src/player.cpp:3642
#10 0x00000000006afa6b in game::draw_sidebar (this=this@entry=0xd2fbce0)
at src/game.cpp:4867
#11 0x00000000006b07f4 in game::draw (this=this@entry=0xd2fbce0)
at src/game.cpp:4831
#12 0x00000000006d9e4d in game::do_turn (this=0xd2fbce0) at src/game.cpp:1543
#13 0x000000000041c97e in main (argc=, argv=)
at src/main.cpp:491

Thread 1 “cataclysm-tiles” received signal SIGSEGV, Segmentation fault.
__memcmp_sse4_1 () at …/sysdeps/x86_64/multiarch/memcmp-sse4.S:1011
1011 …/sysdeps/x86_64/multiarch/memcmp-sse4.S: No such file or directory.
(gdb) backtrace
#0 __memcmp_sse4_1 () at …/sysdeps/x86_64/multiarch/memcmp-sse4.S:1011
#1 0x00007ffff7201278 in std::__cxx11::basic_string<char, std::char_traits, std::allocator >::compare(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) const ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#2 0x0000000000433142 in std::operator< <char, std::char_traits, std::allocator > (
__lhs=<error: Cannot access memory at address 0xfffffffffffffff8>,
__rhs=“REACTOR”) at /usr/include/c++/5/bits/basic_string.h:4989
#3 0x0000000000487392 in std::less<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >::operator() (this=,
__y=“REACTOR”, __x=…) at /usr/include/c++/5/bits/stl_function.h:387
#4 std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::_Identity<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >, std::less<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits, std::allocator > > >::_M_lower_bound (this=, __k=“REACTOR”, __y=0x109651f8,
__x=) at /usr/include/c++/5/bits/stl_tree.h:1644
#5 std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::_Identity<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >, std::less<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits, std::allocator > > >::find (
__k=“REACTOR”, this=0x109651f0) at /usr/include/c++/5/bits/stl_tree.h:2308
#6 std::set<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::less<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits, std::allocator > > >::count (this=0x109651f0,
__x=“REACTOR”) at /usr/include/c++/5/bits/stl_set.h:668
#7 0x00000000005c3663 in vpart_info::has_flag (this=,
flag=“REACTOR”) at src/veh_type.h:205
#8 0x000000000072e458 in vehicle_part::is_reactor (this=this@entry=
0xe329c0 vehicle::current_engine()::null_part) at src/vehicle.cpp:6116
#9 0x000000000072e546 in vehicle_part::ammo_currentabi:cxx11 const (
this=this@entry=0xe329c0 vehicle::current_engine()::null_part)
at src/vehicle.cpp:5844
#10 0x00000000007cc1b2 in player::disp_status (this=0xdcc24f0, w=0xd0946a0,
w2=) at src/player.cpp:3642
#11 0x00000000006afa6b in game::draw_sidebar (this=this@entry=0xd2fbc50)
at src/game.cpp:4867
#12 0x00000000006b07f4 in game::draw (this=this@entry=0xd2fbc50)
at src/game.cpp:4831
#13 0x00000000006d9b21 in game::do_turn (this=0xd2fbc50) at src/game.cpp:1461
#14 0x000000000041c97e in main (argc=, argv=)
at src/main.cpp:491[/code]

I recompiled about 24 hours ago (roughly) after seeing that there were more changes regarding reactors (which seems to have something to do with my segfaults, even though I am not using or afaik around reactors). I haven’t had any problems since and have played a few days in in-game time. Making sure to walk onto shopping carts and other vehicle frames, in the case of shopping carts making sure there are many items in its inventory. No more problems for now so perhaps it was a temporary problem with making a build from experimental when a feature was half-developed. Or maybe now that I make this reply it will happen in a minute (lol), but it’s looking good.

Assuming I have no more of these problems I’m going to take this as a general lesson about using experimental and not be so quick to make a thread in the future. At least it was a little lesson on debugging even though it has limited value to me, having practically no c++ experience (very limited ability to figure out what the code really does). GDB might have pointed me in the right direction on reactors though (if I was correct in my thinking)

I’m having such a good run this time! I think I’ll actually be able to reach “mid game”, I’m on day 7 right now and have quite a collection of stuff, have trained up a lot of useful skills using books (have a whole library at my base), and my base is in a really safe place. I have meds to deal with pretty much all kinds of infections or health problems. Things like water are no longer a concern at all. I really wanted to be able to build up enough to not only survive long term, but specifically do some farming (to make it through winter) and my goal is to build a vehicle (mobile base) of my own. It’s looking pretty good!

My current version since the mentioned recompilation a day ago is 0.C-20111-g0c94833. The only change in compilation options is that I added SOUND=1 and then placed the facepunch sound pack in the folder. Other than that, the same as before, certainly irrelevant

Go figure, I did speak too soon. Was on a raid of a grocery store, loaded up the cart with a ton of stuff, then stepped onto it (to test)

Thread 1 "cataclysm-tiles" received signal SIGSEGV, Segmentation fault. 0x00007ffff6d91256 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (gdb) bt #0 0x00007ffff6d91256 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #1 0x0000000000435bbe in std::operator< <char, std::char_traits<char>, std::allocator<char> > ( __lhs=<error reading variable: Cannot access memory at address 0x500000027>, __rhs="REACTOR") at /usr/include/c++/5/bits/basic_string.h:4989 #2 0x0000000000488bf4 in std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::operator() (this=<optimized out>, __y="REACTOR", __x=...) at /usr/include/c++/5/bits/stl_function.h:387 #3 std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::_Identity<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::_M_lower_bound (this=<optimized out>, __k="REACTOR", __y=0x1c71bc88, __x=<optimized out>) at /usr/include/c++/5/bits/stl_tree.h:1644 #4 std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::_Identity<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::less<std::__cxx11::basic_string<char,---Type <return> to continue, or q <return> to quit--- std::char_traits<char>, std::allocator<char> > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::find ( __k="REACTOR", this=0x1c71bc80) at /usr/include/c++/5/bits/stl_tree.h:2308 #5 std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::count (this=0x1c71bc80, __x="REACTOR") at /usr/include/c++/5/bits/stl_set.h:668 #6 0x00000000005c88d1 in vpart_info::has_flag (this=<optimized out>, flag="REACTOR") at src/veh_type.h:208 #7 0x0000000000735238 in vehicle_part::is_reactor (this=this@entry= 0xe38fc0 <vehicle::current_engine()::null_part>) at src/vehicle.cpp:6037 #8 0x0000000000735326 in vehicle_part::ammo_current[abi:cxx11]() const ( this=this@entry=0xe38fc0 <vehicle::current_engine()::null_part>) at src/vehicle.cpp:5743 #9 0x00000000007d2570 in player::disp_status (this=0x17e7be70, w=0xd0b2500, w2=<optimized out>) at src/player.cpp:3642 #10 0x00000000006b4315 in game::draw_sidebar (this=this@entry=0x12845f40) at src/game.cpp:4866 #11 0x00000000006b509e in game::draw (this=this@entry=0x12845f40) at src/game.cpp:4830 #12 0x00000000006de79e in game::do_turn (this=0x12845f40) at src/game.cpp:1543 #13 0x000000000041d718 in main (argc=<optimized out>, argv=<optimized out>) ---Type <return> to continue, or q <return> to quit--- at src/main.cpp:491

Anyways since I know how to avoid it (don’t step on the cart), I won’t post about it again unless I see somebody else post about this and I think I can be useful

Stack trace is very helpful and will probably lead to fix. Opening a github issue with that stack trace would be be helpful.

Thanks Mugling I’ll do that soon

Edit: I added this on github Segfault when stepping onto same tile as Shopping Cart · Issue #19676 · CleverRaven/Cataclysm-DDA · GitHub

Edit2: This should now be fixed. Thanks to Coolthultu for learning me a bit about gdb and compiling with symbols, thanks to remyroy for finding the issue, kevingranade and codemime for the fix, and also Rivet-the-Zombie and everybody else involved.

The fix: Hide vpart_info::id behind an accessor. · CleverRaven/Cataclysm-DDA@4e66a4c · GitHub