jkulawik / tdd-issues

Bug tracker for "Amnesia: The Dark Descent" v1.5
0 stars 0 forks source link

Main campaign - Crash in Entrance Hall #23

Open Mudbill opened 3 months ago

Mudbill commented 3 months ago

There's a BlackBox crash to desktop occurring in the Entrance Hall map after completing the Archives. It happens at the end of the Shadow slime spawning event.

Based on what I've looked into, I suspect it's caused by an array out of bounds exception in the .hps script file. It's possible this error has existing since the dawn of time, but previously the game would simply halt a function when such an exception occurred. It seems this is no longer the case with the new exception detection features, and could be causing the crash.

hpl.log prints this upon crashing:

ERROR: Script exception in module maps/main/02_entrance_hall.hps, function void TimerGuardSlime(string&in): Out of range at line 161, column 3
ERROR: Error calling cached script func handle 'Map_02_entrance_hall :: void TimerGuardSlime(string&in) - Execution raised an exception'

The relevant script for 02_entrance_hall.hps is this:

else if(asTimer == "guard3") {
    /* omitted */

    string[] aSlime = {     "slime_pile_large3_1","slime_pile_large3_2","slime_pile_large3_3","slime_pile_large3_4","slime_pile_large3_5",
                "slime_pile3_1","slime_pile3_2","slime_pile3_3","slime_pile3_4","slime_pile3_5",
                "slime_pile3_6","slime_pile3_7","slime_pile3_8","slime_pile3_9","slime_pile3_10",
                "slime_anim_wall3_1","slime_anim_wall3_2","slime_anim_ceiling3_1",
                "slime_6way3_1","slime_6way3_2","slime_6way3_3","slime_6way3_4","slime_6way3_5",
                "slime_egg3_1","slime_egg3_2","slime_egg3_3","slime_egg3_4","slime_egg3_5",
                "slime_3way3_1","slime_3way3_2","slime_3way3_3","slime_3way3_4"};
    ::aSlime = aSlime;
}

/* omitted */

for(int iSlime=0;iSlime<=aSlime.length();iSlime++) {
    int iRand = RandFloat(5,8);

    SetPropActiveAndFade(aSlime[iSlime], true, iRand);

    for(int i=0;i<=iRand;i++)
        AddTimer(aSlime[iSlime], RandFloat(1,iRand-1), "TimerSlimeSounds");
}

Line 161 is the first for-loop: for(int iSlime=0;iSlime<=aSlime.length();iSlime++) {

I think the issue is that it's "off-by-one" in that it gets aSlime[iSlime] when iSlime is equal to the length of the aSlime array, due to it looping as long as it is "less than or equal" instead of just "less than."

crater0 commented 3 months ago

The game shouldn't crash at all upon a runtime exception, so that should definitely be fixed even if the off by one error isn't.

Was this run into while playing without debug mode? Might be related to some previous crashes that occured when the debug window wasn't present.

Never mind, red herring. Confirmed to be a different issue relating to pointers.