[4.2.4] AActor::SetState infinite loop, freezing game (DRPG)

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Post Reply
User avatar
Sumwunn
Posts: 54
Joined: Sat Jan 06, 2018 12:00 pm

[4.2.4] AActor::SetState infinite loop, freezing game (DRPG)

Post by Sumwunn »

Hello, I'm back with another obscure bug in relation to DRPG and it appears to be unrelated to HUDMessage this time.

So thankfully someone was able to send me a savegame that freezes seconds after loading, something I've been attemping to replicate for far too long.

AFAIK, It seems to be stemming from p_mobj.cpp#L495, and the do-while loop gets stuck and loops for infinity unless if I force line 497 to exit with x64dbg and in which case the engine resumes as normal and no more freezes are witnessed in the next five minutes.

I noticed that AActor::SetState barely registers on the CPU profiler until the freeze happens.
Another thing I noticed was that this freeze seems to go as far back as v3.7.2 and probably earlier.

Here's some info from VS profiler:
https://i.imgur.com/ok6ZuJQ.jpg

Links to save game and the VS profiler report.
https://www.mediafire.com/file/rgv0jux0 ... 0.zip/file
https://www.mediafire.com/file/06m1g854 ... 6.zip/file

I understand DRPG is a pain to setup and test, so feel free to tell me what to change.

Need anymore info? Please scream. Thanks!

How to run:
Spoiler:
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [4.2.4] AActor::SetState infinite loop, freezing game (D

Post by Graf Zahl »

There is only one way that loop can get stuck and that is if some actor has a 0-duration state loop. This is one of those cases which cannot really be fixed in the engine because the only way to end the loop would be to set an arbitrary maximum loop count. Set it too low and other mods will break, set it too high and it becomes ineffective.
User avatar
Sumwunn
Posts: 54
Joined: Sat Jan 06, 2018 12:00 pm

Re: [4.2.4] AActor::SetState infinite loop, freezing game (D

Post by Sumwunn »

Thank you for the info, that's certainly interesting.

So how does one identify whether an actor is affected by a 0-duration state loop? Would it be in a the form of user error in decorate?

DRPG manages its monster compatibility via duplicating actors and basically forcing DRPGs MonsterInit to execute via state modification, could that possibly be an issue? I never did like having to duplicate actors for compatibility sake.
https://github.com/Sumwunn/DoomRPG/blob ... ers.txt#L8
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [4.2.4] AActor::SetState infinite loop, freezing game (D

Post by Graf Zahl »

While some obvious cases can be detected, those are rarely the problem. Where it goes wrong is often things that look correct on the surface but still do not work properly, like A_Jump combinations with no delays and conditions that evaluate to results that SetState never exits the loop.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: [4.2.4] AActor::SetState infinite loop, freezing game (D

Post by _mental_ »

If this helps, the actor in question is RLUniqueBossSpawner, and the state that loops endlessly is RLUniqueBossSpawner.102 which seems to be Succeed from the actor below.
Spoiler: RLUniqueBossSpawner
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [4.2.4] AActor::SetState infinite loop, freezing game (D

Post by Graf Zahl »

More like the stuff above "Succeed". Succeed is harmless, it just waits and ends, the SpawnLoop above is just horrible code.
User avatar
Sumwunn
Posts: 54
Joined: Sat Jan 06, 2018 12:00 pm

Re: [4.2.4] AActor::SetState infinite loop, freezing game (D

Post by Sumwunn »

Thanks for the actor name! It seems HEYSTOPTHAT is the culprit when DRPG is active which would explain why DRLA by itself does not freeze the game.

Changing TNT1 A from 0 to 1 avoids the freeze up, and judging from the function's structure it looks like RLDemonicBossSpawner is susceptible also.
I'm not sure about the other checks scattered around as they are a bit different from this case, however I managed to figure out VS debugger so if this happens again I can see the actor responsible.

I think this wraps things up assuming the above is the correct way to solve this.

EDIT:
I think I've properly fixed it, had to copy over the DoorpegOutpostCheck section from RLDemonicBossSpawner to RLUniqueBossSpawner's empty one, and a UniqueBoss spawned so I'm guessing that's the intended behaviour.

EDIT 2:
The fix will be included in the next DRLA update, so this can be closed.

Thanks guys.
User avatar
Major Cooke
Posts: 8175
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: [4.2.4] AActor::SetState infinite loop, freezing game (D

Post by Major Cooke »

What about a debug variable that can be set where modders can use this as a tool, Graf? If it's set to < 1 then it doesn't perform.
Post Reply

Return to “Closed Bugs [GZDoom]”