[Fixed] "for (;;)" in ZScript crashes GZDoom

Bugs that have been investigated and resolved somehow.

Moderator: Developers

"for (;;)" in ZScript crashes GZDoom

Postby phantombeta » Thu Sep 13, 2018 8:44 pm

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 7 times
User avatar
phantombeta
In the meadow of sinful thoughts, every flower's a perfect one
 
Joined: 02 May 2013
Location: The United Soviet Socialist Dictatorship of Hueland
Discord: phantombeta#2461
Twitch ID: phantombeta_

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

Postby Graf Zahl » Fri Sep 14, 2018 1:14 am

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
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

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

Postby phantombeta » Fri Sep 14, 2018 2:58 am

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.
User avatar
phantombeta
In the meadow of sinful thoughts, every flower's a perfect one
 
Joined: 02 May 2013
Location: The United Soviet Socialist Dictatorship of Hueland
Discord: phantombeta#2461
Twitch ID: phantombeta_

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

Postby _mental_ » Fri Sep 14, 2018 3:16 am

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_
 
 
 
Joined: 07 Aug 2011

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

Postby _mental_ » Sat Sep 15, 2018 8:44 am

Fixed in 7d1af25.
_mental_
 
 
 
Joined: 07 Aug 2011


Return to Closed Bugs

Who is online

Users browsing this forum: No registered users and 0 guests