-
Notifications
You must be signed in to change notification settings - Fork 4
TR2X bug: Rare crash in Barkhang Monastery #137
Comments
I can't reproduce this – would appreciate more detailed testing instructions. CC-ing @lahm86 as he's been of great help tracking down the root cause of the previous crash. |
I'll gladly take a look at this tomorrow. IIRC there is an untriggerable enemy in that area with "consumed" pickups, perhaps that's a lead. |
I'm struggling to reproduce this too, or find any lead. I don't suppose you have a save from when you played the level, just prior to this area maybe? And what order did you do the level in? Just thinking it may depend on which items are active elsewhere in the level. |
Yep, I got 3 save files prior to this crash: savegame.zip. Crash 3 was after savegame.2 when I was trying to reproduce it, but I had little luck getting the game to crash since then. This is the first prayer wheel I collected. I have not used the key yet to access the main hall with the buddhist statue. If it helps, I also retraced my steps through the level to the best of my recollection, on trview: Route.zip Also no monks died before this point. |
Thanks for the detailed information. I've still not managed to reproduce it unfortunately, so I'm not sure at all what the cause could be. There is nothing abnormal going on in this area from what I can tell, all items that are active are "running" normally, and effects seem to be OK. I'll continue trying to recreate it though. |
Thank you @lahm86, I appreciate you looking into this issue. The good news is I've managed to get crash 4 to happen on video. One notable difference is this crash happened before the room got flipped. At the end of the video, I was holding down action so Lara can stay locked onto the goon. Video: https://drive.google.com/drive/folders/1dttvc2gIHps7h6duhKQKc1SQ6Gm8nA2z?usp=sharing |
Thanks. Still no luck at this end 😄 |
No problem at all. I must be lucky because I've managed to trigger a crash on 2nd try after adding your build. Log: TR2X.zip It went roughly like this:
I'm actually not sure what was happening when the crash occurred after step 8, I think Lara was still in the fire room. Saves 6 & 7, for good measure: savegame.zip |
Thanks. So the good news is I've managed to get it to crash as well, and it matches up with your crash, in that this is the final debug message before the crash.
So that points to it being something in this enemy's control that is at fault. He is triggered when the prayer wheel is collected. But equally, this doesn't explain the crash you had before picking up the prayer wheel, so I'm thinking it's more a general thing in the mercenary1 control. That code isn't decompiled yet, but the I'm also wondering if this is potentially an OG bug in the mercenary control, but I imagine that, although it's quite difficult to reproduce, someone in the community would have noticed it before. I know Barkhang can get buggy with traps and doors freezing, but I don't think I've seen the crash before in OG. |
Some progress (it is crashing on latest dev build after all), Will continue trying to backtrace to see where this is coming from. |
I can't find a lead as to what's corrupting the room number. Everything in |
It took me a while to to trigger a crash, this time it happened before collecting the prayer wheel. Dev snapshot: 0.2-236-g613af1c |
WTF why there's no stack trace :D |
Right, these are still release builds… That explains the missing stack trace. I'll change the dev snapshot to produce debug symbols from now on 🤦♀️ |
@aredfan the latest dev snapshot now contains debug symbols and should have the new stack trace capture working. The asset is significantly larger as it's no longer compressed with UPX unlike release builds. |
I can't reproduce it. I was going to just leave the game alt-tabbed until it crashed while I did other things, but my game pauses on minimize. Maybe aredfan will get lucky with this debug build with more log information. |
I think I've found something in Judging by TR1X, target's My guess is that in OG, the garbage room number turns out to be within the valid room range by chance, so the OG You can simulate a crash by setting x/z to match on
Here is a proposed patch, but I don't really like having to set diff --git a/src/game/los.c b/src/game/los.c
index bd338a0..1b0799f 100644
--- a/src/game/los.c
+++ b/src/game/los.c
@@ -263,6 +263,10 @@ int32_t __cdecl LOS_Check(
int32_t los1;
int32_t los2;
+ if (target->room_num < 0 || target->room_num >= g_RoomCount) {
+ target->room_num = NO_ROOM;
+ }
+
if (ABS(target->z - start->z) > ABS(target->x - start->x)) {
los1 = LOS_CheckX(start, target);
los2 = LOS_CheckZ(start, target);
@@ -271,7 +275,7 @@ int32_t __cdecl LOS_Check(
los2 = LOS_CheckX(start, target);
}
- if (!los2) {
+ if (!los2 || target->room_num == NO_ROOM) {
return 0;
} |
Nice find. I don't think I've ever seen a reported crash like this for the OG games though. Even though it's rare, you'd think there would be reports over the years. Is there some added safety check or change that would caused us to be getting this? |
My only assumption is that it could be a difference on the stack because of changes in TR2X elsewhere? The room number is consistently 1280 when it's crashing (for this particular scenario), so I can only guess in OG the value is within the room range. |
@lahm86 based on the recently decompiled functions, I think you're theory is exactly right. The only odd thing is this seemingly never happening in OG TR2 for some reason. But anyway, It's probable we may also need to decompile IMO, instead of initializing to |
This avoids cases with enemies fighting one another where x and z positions are identical and so LOS_Check does not initialise the target room number and hence later passes an invalid room number to Room_GetSector. Resolves LostArtefacts#137.
This avoids cases with enemies fighting one another where x and z positions are identical and so LOS_Check does not initialise the target room number and hence later passes an invalid room number to Room_GetSector. Resolves LostArtefacts#137.
Dev snapshot: 0.2-227-g6e863b2
The cause or steps to reproduce this crash is TBD. Hopefully this issue will provide a clue to help figure out a fix.
The waypoints shown below mark the 3 places I experienced a crash. In all cases, it was after Lara collected a Prayer Wheel in room 45.
The text was updated successfully, but these errors were encountered: