Jump to content
The Dark Mod Forums

Crash in 2.12


joebarnin

Recommended Posts

My new FM is in beta test, and some testers are using 2.12. They have discovered a hang/crash that only happens in 2.12 (crash doesn't happen in 2.11). I am able to recreate it in 2.12 now. I run TDM in the Visual Studio debugger (using dev16829-10455). After starting the mission, I just wait a minute or so and the screen freezes. Then, I wait another couple of minutes, and the debugger reports a failed assertion. The assertion is:

WARNING:ASSERTION FAILED! E:\games\darkmod_source212\idlib\containers\List.h(394): 'newsize >= 0'

The callstack is:

     TheDarkModx64_debug.exe!AssertFailed(const char * file, int line, const char * expression) Line 75    C++
>    TheDarkModx64_debug.exe!idList<idPlane>::Resize(int newsize) Line 394    C++
     TheDarkModx64_debug.exe!idList<idPlane>::AddGrow(idPlane obj) Line 765    C++
     TheDarkModx64_debug.exe!idRenderWorldLocal::FloodLightThroughArea_r(idRenderWorldLocal::FlowLightThroughPortalsContext & context, int areaNum, const portalStack_s * ps) Line 351    C++
     TheDarkModx64_debug.exe!idRenderWorldLocal::FloodLightThroughArea_r(idRenderWorldLocal::FlowLightThroughPortalsContext & context, int areaNum, const portalStack_s * ps) Line 385    C++
     TheDarkModx64_debug.exe!idRenderWorldLocal::FloodLightThroughArea_r(idRenderWorldLocal::FlowLightThroughPortalsContext & context, int areaNum, const portalStack_s * ps) Line 385    C++
     TheDarkModx64_debug.exe!idRenderWorldLocal::FloodLightThroughArea_r(idRenderWorldLocal::FlowLightThroughPortalsContext & context, int areaNum, const portalStack_s * ps) Line 385    C++
     TheDarkModx64_debug.exe!idRenderWorldLocal::FloodLightThroughArea_r(idRenderWorldLocal::FlowLightThroughPortalsContext & context, int areaNum, const portalStack_s * ps) Line 385    C++
     TheDarkModx64_debug.exe!idRenderWorldLocal::FloodLightThroughArea_r(idRenderWorldLocal::FlowLightThroughPortalsContext & context, int areaNum, const portalStack_s * ps) Line 385    C++
     TheDarkModx64_debug.exe!idRenderWorldLocal::FloodLightThroughArea_r(idRenderWorldLocal::FlowLightThroughPortalsContext & context, int areaNum, const portalStack_s * ps) Line 385    C++
     TheDarkModx64_debug.exe!idRenderWorldLocal::FloodLightThroughArea_r(idRenderWorldLocal::FlowLightThroughPortalsContext & context, int areaNum, const portalStack_s * ps) Line 385    C++
     TheDarkModx64_debug.exe!idRenderWorldLocal::FloodLightThroughArea_r(idRenderWorldLocal::FlowLightThroughPortalsContext & context, int areaNum, const portalStack_s * ps) Line 385    C++
     TheDarkModx64_debug.exe!idRenderWorldLocal::FloodLightThroughArea_r(idRenderWorldLocal::FlowLightThroughPortalsContext & context, int areaNum, const portalStack_s * ps) Line 385    C++
     TheDarkModx64_debug.exe!idRenderWorldLocal::FloodLightThroughArea_r(idRenderWorldLocal::FlowLightThroughPortalsContext & context, int areaNum, const portalStack_s * ps) Line 385    C++
     TheDarkModx64_debug.exe!idRenderWorldLocal::FloodLightThroughArea_r(idRenderWorldLocal::FlowLightThroughPortalsContext & context, int areaNum, const portalStack_s * ps) Line 385    C++
     TheDarkModx64_debug.exe!idRenderWorldLocal::FloodLightThroughArea_r(idRenderWorldLocal::FlowLightThroughPortalsContext & context, int areaNum, const portalStack_s * ps) Line 385    C++
     TheDarkModx64_debug.exe!idRenderWorldLocal::FloodLightThroughArea_r(idRenderWorldLocal::FlowLightThroughPortalsContext & context, int areaNum, const portalStack_s * ps) Line 385    C++
     TheDarkModx64_debug.exe!idRenderWorldLocal::FloodLightThroughArea_r(idRenderWorldLocal::FlowLightThroughPortalsContext & context, int areaNum, const portalStack_s * ps) Line 385    C++
     TheDarkModx64_debug.exe!idRenderWorldLocal::FlowLightThroughPortals(idRenderLightLocal * light, idFlexList<int,128> * areaIds, lightPortalFlow_t * portalFlow) Line 495    C++
     TheDarkModx64_debug.exe!idRenderWorldLocal::AddLightToAreas(idRenderLightLocal * def) Line 2038    C++
     TheDarkModx64_debug.exe!R_CreateLightRefs(idRenderLightLocal * light) Line 738    C++
     TheDarkModx64_debug.exe!idRenderWorldLocal::UpdateLightDef(int lightHandle, const renderLight_s * rlight) Line 423    C++
     TheDarkModx64_debug.exe!idLight::PresentLightDefChange() Line 1076    C++
     TheDarkModx64_debug.exe!idLight::Present() Line 1132    C++
     TheDarkModx64_debug.exe!idEntity::Think() Line 2318    C++
     TheDarkModx64_debug.exe!idLight::Think() Line 1274    C++
     TheDarkModx64_debug.exe!idGameLocal::RunFrame(const usercmd_t * clientCmds, int timestepMs, bool minorTic) Line 3366    C++
     TheDarkModx64_debug.exe!idSessionLocal::RunGameTic(int timestepMs, bool minorTic) Line 3063    C++
     TheDarkModx64_debug.exe!idSessionLocal::RunGameTics() Line 3109    C++
     TheDarkModx64_debug.exe!idSessionLocal::FrontendThreadFunction() Line 3159    C++
     TheDarkModx64_debug.exe!idSessionLocal::StartFrontendThread::__l2::<lambda>(void * x) Line 3235    C++
     TheDarkModx64_debug.exe!unsigned int <lambda>(void *)::<lambda_invoker_cdecl>(void * x) Line 3236    C++
     [External Code]    

The code in question:

ID_INLINE int idList<type>::AddGrow( type obj ) {
    if ( num == size ) {
        int newsize;

        if ( granularity == 0 ) {    // this is a hack to fix our memset classes
            granularity = 16;
        }
        newsize = (size * 3) >> 1;            // + 50% size
        newsize += granularity;                // round up to granularity
        newsize -= newsize % granularity;    //
        Resize( newsize );
    }

    list[ num ] = obj;
    num++;

    return num - 1;
}

size = 968651120, so newsize is calculated as  -694506944, which causes the assertion.

Obviously something is running away and the code ends up trying to resize the list to a size that is so big that it wraps around to negative. Is my mod doing something wrong that is leads to this? How do I track this down? I can supply the FM package if that will help. Or, I can set some breakpoints if there's something I can look at here.

Thanks.

Edit: Here's the FM: https://www.dropbox.com/scl/fi/3fg2x3w4owmku1l4gifi7/altham_crash.pk4?rlkey=z0q1gaflz5b7mifeuayoqmlug&dl=1

To reproduce the problem, start the mission (Easy difficulty), then just stand there. The guard will walk close to you but he shouldn't see you (you can always set the "notarget" console command to ensure he doesn't see you). After a few minutes, the game freezes. A few minutes after that, it crashes. Sometimes it happens in just a minute or two; other times it takes several minutes. But so far, it always happens eventually.

Edited by joebarnin
provide test case
  • Like 3
Link to comment
Share on other sites

Wow!
This is something interesting.

You have areas 177 and 179 (you can detect them using teleportArea command) with 8 visportals between them, all in same plane.
I hope this is as intended, and you really have many separate visportals?
This should be perfectly valid of course.

FloodLightThroughPortals searches for all visportal sequences which might get some light rays through.
For some reason, it manages to go back and forth between areas 179 and 177 something like eight times in the same sequence.

It is not forbidden for the traversal to go through the same area many times, but it is forbidden to go through oriented visportal twice. However, there are too many possible sequences of going through 8 two-sided visportals, and the code obviously tries to enumerate and save them all. At some point it bumps into 32-bit integer limits and everything crashes. By this moment it has wasted 32 GB of RAM so I don't think it would live long even if it did not crash here.

You don't have the issue in 2.11 because:

  1. This is a dynamic light from some lantern bot, TDM 2.11 only runs this function for static lights.
  2. TDM 2.11 does not try to save all sequences, it would only enumerate them in horrendously slow time.

I think some lantern bot crosses the visportal between areas 179 and 177 at this moment, causing the issue.
Also, you can most likely reproduce it in 2.11 by putting a large enough light at the same location (12565.0205, 411.300110, 522.249939).

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

I guess I'll try to reproduce it in a testmap.

Like there are two rooms with a planar wall between them.
There are 25 windows in this wall (e.g. arranged as 5 x 5 grid), each window has a visportal.
There is a moveable light source which covers the whole wall.
If player tried to move it between rooms (e.g. through a door), then everything hangs up and crashes, hopefully 🥳

Link to comment
Share on other sites

Thanks for the explanation. The building where this happens is an "open plan" warehouse, 4 stories, with a wall at one end but 2 doorways in the wall on each side, so 8 total:

image.thumb.jpeg.9a3b599c22f6ee4bac59b4547bf9a8bd.jpeg

Each doorway is a visportal. They are lined up on the X-plane.

First question, are all of these portals unnecessary? They do reduce the tris somewhat, but maybe not worth it? Second question, I recall occasional problems when visportals are lined up exactly. Maybe I'll move each of them a slightly different amount in the x direction, see if that helps.

I'll experiment and let you know what I find.

Link to comment
Share on other sites

So I adjusted each portal slightly in the x direction. The portals were 8 x 112 x 128 (x,y,z), and I moved the x-plane of each portal by a different amount (1 unit, 2 units, 3 units, etc), so that none of them are in the same plane. And now it no longer crashes! So I have a workaround, at least.

Thanks for identifying the root of the problem! Let me know if there's anything else I can do; for now, I'm going to proceed with my workaround.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • nbohr1more

      Was checking out old translation packs and decided to fire up TDM 1.07. Rightful Property with sub-20 FPS areas yay! ( same areas run at 180FPS with cranked eye candy on 2.12 )
      · 2 replies
    • taffernicus

      i am so euphoric to see new FMs keep coming out and I am keen to try it out in my leisure time, then suddenly my PC is spouting a couple of S.M.A.R.T errors...
      tbf i cannot afford myself to miss my network emulator image file&progress, important ebooks, hyper-v checkpoint & hyper-v export and the precious thief & TDM gamesaves. Don't fall yourself into & lay your hands on crappy SSD
       
      · 5 replies
    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 7 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
×
×
  • Create New...