Code generation crash with ZetaBot 0.3.0

Thu Mar 07, 2019 10:46 am

From the ZetaBot dev thread, I tried running the latest release from the project's GitHub page and got this:

Code:
gzdoom: gzdoom/src/scripting/backend/codegen.cpp:2319: virtual ExpEmit FxPostIncrDecr::Emit(VMFunctionBuilder*): Assertion `ValueType == Base->ValueType && IsNumeric()' failed.


I'm not the dev obviously, just remembered it existed and wanted to try it out.

Re: Code generation crash with ZetaBot 0.3.0

Thu May 09, 2019 4:20 pm

This issue does not happen with the latest stable version of GZDoom. In the case of the ZetaBot, it was temporarily fixed in ZetaBot v0.4.0 merely by fiddling with the source code (it seemed to be related to certain patches of code (most likely from Standard.zsc), which were refactored, though I don't recall which - try reading diffs), but it returned in a later version (and still exists, as of v0.7.0) for an unknown reason.

Re: Code generation crash with ZetaBot 0.3.0

Thu May 09, 2019 4:56 pm

Gustavo6046 wrote:This issue does not happen with the latest stable version of GZDoom. In the case of the ZetaBot, it was temporarily fixed in ZetaBot v0.4.0 merely by fiddling with the source code (it seemed to be related to certain patches of code (most likely from Standard.zsc), which were refactored, though I don't recall which - try reading diffs), but it returned in a later version (and still exists, as of v0.7.0) for an unknown reason.

The latest stable version is a Release build. Assertions only happen in Debug builds.

Re: Code generation crash with ZetaBot 0.3.0

Thu May 09, 2019 5:03 pm

Yet, there is probably an issue if the assertion is meant to denote something is wrong, yet whatever condition it tries to prohibit is silently ignored in Release builds. I'll try to build GZDoom as a Release build via CMake, and see if any significant issue appears. Thank you.

Re: Code generation crash with ZetaBot 0.3.0

Mon May 13, 2019 3:55 am

Here is the minimal sample. The problem is in type mismatch (signed vs. unsigned) for increment/decrement operators.
Code:
class IncrDecrTypeMismatch
{
   void Test()
   {
      int a = 0;

      // These lines trigger assertion failures
      uint b = a++;
      uint c = --a;
      
      // These do not
      uint b; b = a++;
      uint c; c = --a;
   }
}

Curiously enough, typecasts are present for both local variable declarations and assignments in the sample above.
However, they are different in unsigned flag propagation, compare this cast (called from FxLocalVariableDeclaration::Resolve) with assignment.