"for (;;)" in ZScript crashes GZDoom

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
phantombeta
Posts: 2084
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

"for (;;)" in ZScript crashes GZDoom

Post by phantombeta »

Exactly what it says on the thread title.

Steps to reproduce:
  • Start a new game with the attached PK3 loaded
  • Summon "TestActor"
Based on a few observations, I'm guessing either the compiler backend or the compiler frontend is compiling it completely wrong. It doesn't even start if you replace the "for (;;)" loop with a "while (true)" loop, as it errors out with the "Return type mismatch" error, which doesn't happen at all with the "for (;;)" loop.
Attachments
ZScriptForLoopCrash.pk3
(265 Bytes) Downloaded 23 times
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: "for (;;)" in ZScript crashes GZDoom

Post by Graf Zahl »

The return type mismatch is because the compiler is not smart enough to detect that the end of the loop is never reached. So it sees both a boolean return and a void return and complains about it.
I cannot run this myself until late this evening, so if you could run this thing with "-dumpdisasm" and post the output I may give some feedback earlier.
User avatar
phantombeta
Posts: 2084
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: "for (;;)" in ZScript crashes GZDoom

Post by phantombeta »

Graf Zahl wrote:The return type mismatch is because the compiler is not smart enough to detect that the end of the loop is never reached. So it sees both a boolean return and a void return and complains about it.
Yeah, I'm aware of that, which is why I suspect something is going horribly wrong when it tries to compile the "for (;;)" loop.
... Which the disassembly seems to agree with. There's no disassembly for TestActor's "a" function in it at all.
Here's the disassembly if you want to take a look.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: "for (;;)" in ZScript crashes GZDoom

Post by _mental_ »

Code of such for loop is not generated at all. Made PR with the fix to be sure that it's OK to fix the problem this way.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: "for (;;)" in ZScript crashes GZDoom

Post by _mental_ »

Fixed in 7d1af25.
Post Reply

Return to “Closed Bugs [GZDoom]”