Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upCrash when something falls into a giant sinkhole. #28679
Comments
KorGgenT
added
<Crash / Freeze>
Z-levels
Monsters
labels
Mar 13, 2019
This comment has been minimized.
This comment has been minimized.
|
Guess if #28545 has something to do with this? |
This comment has been minimized.
This comment has been minimized.
|
Probably related: could't get a crash in a world with experimental Z-levels turned on. |
ZhilkinSerg
added
the
(S2 - Confirmed)
label
Mar 30, 2019
This comment has been minimized.
This comment has been minimized.
neitsa
referenced this issue
Apr 6, 2019
Closed
Crash at the second floor of the research facility #29323
This comment has been minimized.
This comment has been minimized.
|
This bug is interesting but not necessarily really easy to solve. I also wonder why it hasn't manifested more than that (it seems the code involved here is at least 4 years old). Start with the code here in
We got a monster from a (hostile) faction and call
As you can see The
So, in this precise case, calling As of now, the list of classes derived from
This probably requires a thorough investigation. |
This comment has been minimized.
This comment has been minimized.
|
What about making rate_rarget accept a Creature pointer? Then it can dispatch to monster::pos(). In general, Creature is treated as pure virtual, I'm not sure why it was even allowed to get this far (passing Creature as a reference). |
This comment has been minimized.
This comment has been minimized.
|
Did you try casting to monster? |
This comment has been minimized.
This comment has been minimized.
|
Thank you both for your answers!
I could have "upcasted" (and I guess it would work) but there's a risk that this function might be called with something else than a monster (e.g an NPC or the player). to answer your question, no I haven't tried, even for a test. I'll do!
I haven't tried yet. Will do! I'm still puzzled why polymorphism doesn't work here... We discussed this with @ifreund yesterday but we couldn't come to a definitive conclusion :) |
This comment has been minimized.
This comment has been minimized.
|
There are functions which check what given Creature reference really is and cast it to whatever necessary in given context, e.g.: Lines 5424 to 5493 in 71b58ff |
This comment has been minimized.
This comment has been minimized.
|
Did another round of tests today, without any luck... Keeping the reference and using a
Obviously, calling is_monster() (in the calling function) gives
Changing
I read some literature online to get an idea what could trigger a pure virtual call and it always seems to be related to constructors and destructors calling a virtual function. I spent a good deal of time in the ctor() and dtor() for Repro fileNote: I'm attaching a save file which has a good chance to trigger the bug. It's not a 100% chance but in at least 50% of the time you'll hit the problematic code and one of the monsters given by the caller will trigger the bug. You'll start on a staircase (going up), then don't do anything besides pressing "<" to go upstairs. It might trigger. I don't think the config really matters here. Zip file SHA-1 hash: A7C5003525E384D858D572DD49BFF5A0B7543DAB |
neitsa
referenced this issue
Apr 27, 2019
Closed
Unexpected Termination Segmentation Fault crashes #29681
This comment has been minimized.
This comment has been minimized.
|
I finally understood the problem, although it took me quite a good deal of time. It basically breaks down to a user-after-free problem. I used the save file from @scrubs2009 in #29681 which was really helpful because I could trigger the bug in just 3 keys press, 100% of the time (and also the save file was small so I could easily spot the offending monster). So thanks a lot scrubs! :) TL;DRWhen you change your z-level, all monsters on the level starts doing their moves in On the first iteration of this loop (or if the map is shifted), it builds the monster factions (basically, zombies are in the "zombies" faction, dogs in the "dogs" factions, etc.). It happens that a monster might fall down a z-level because it was (or has moved at some point) on a trap. As the monster is not anymore on the same z-level as the player, the monster is simply deleted by the game, but it is not deleted from its monster faction. Next, when AnalysisSo everything starts when the player actually change its z-level (by going down in this case) . Note that I really do think that the bug probably can not be triggered if z-level is on.
So when you go down, the monster on the level you are going to have their turns and start doing their stuff. The majority of the things going on there are happening in This function is basically a loop, going on for each monster in your z-level. It start by filling the monster factions on the first iteration, which will be used later in
Now in the same function (in the above big loop iterating on all monsters) we have this other loop:
Now if the monster move onto a trap (during
The monster is then removed from the current z-level map (it is not deleted yet, just removed from the map). We then proceed to the next monster on the current z-level (next iteration of the big loop). Remember that the faction lists are not changed since they are only changed during the first iteration and if the map is shifted. On the next iteration we start with the big loop once again:
This time, the
It's far from being obvious but the
Which then calls
And the above assignment just delete the monster. I was able to confirm that the problematic monster was deleted here (valid pointer before the call, invalid after; and the pointer is later used in Next, in the big loop, the current monster (which is a valid one) will call
As you may notice, the monster factions are passed in argument to The crash itself has already been explained in the previous posts above. FixI don't have a precise idea yet on how to fix this bug, I just finished debugging the crash. I guess the monster factions could be rebuilt when one of the monster has disappeared from the map. |
This comment has been minimized.
This comment has been minimized.
|
That explains why those crashes only really happen when changing Z levels! Great! I'm glad lab towers will hopefully soon be a viable place to live in without worrying about crashes trapping you on the top floor. I do have one extra thing to note. Updating the game through the launcher, even if already on the current version, fixes whichever crash you were having before you updated. If I had to guess (and this is a complete guess) I would think maybe the launcher's process of updating, copying, and deleting old files clears the monster faction lists to repopulate them with new monsters, therefore getting rid of the now broken one. Either way, great job and I'm happy I could help. |

kaitianderson commentedMar 13, 2019
•
edited
Describe the bug
Was near a giant sinkhole when a gracken was chased into it. Game crashed as soon as it stepped in.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Didn't expect a crash.
Screenshots


If applicable, add screenshots to help explain your problem.
Had this error report, then clicked OK and got this one:
Tried to reproduce and got this one:

Versions and configuration(please complete the following information):
"dda",
"no_npc_food",
"filthy_morale",
"novitamins",
"Medieval_Stuff",
"makeshift",
"More_Survival_Tools",
"no_mutagen",
"growable-pots",
"mutant_npcs"
Additional context
Crash Log: crash.log
This is my first bug report, let me know if I messed up. Thanks!
Edit: No crash with Z-levels turned on at world gen.