[Fixed] [4.2.1] JIT crash with "out vector2" as parameter.

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

[4.2.1] JIT crash with "out vector2" as parameter.

Postby Martha Goodworth » Mon Oct 07, 2019 4:42 am

Crash message: "JIT: sfunc->NumArgs != argsPos || regd > sfunc->NumRegD || regf > sfunc->NumRegF || rega > sfunc->NumRegA"

The message above always shows up in the example below. Before isolating the faulty code, the game simply froze and crashed with no message, unless I initialized the variable inside the method with, say, (0, 0).

Example: https://drive.google.com/open?id=1MzRdl ... XOWFuLTeZC
Martha Goodworth
 

Re: [4.2.1] JIT crash with "out vector2" as parameter.

Postby phantombeta » Mon Oct 07, 2019 5:02 am

Some testing with an alternate example indicates this likely isn't the JIT's fault at all, and is probably just a case of the JIT being less forgiving of broken bytecode.
Code: Select allExpand view
class BEPlayerBase : DoomPlayer
{
   private void CheckCursorMovement(out vector2 CursorPosition, int maxWidth, int maxHeight)
   {
      Console.Printf ("%f, %f", CursorPosition.X, CursorPosition.Y);
   }

   vector2 SomeGridCoords;

   override void Tick()
   {
      int buttons = player.original_cmd.buttons;
      int oldbuttons = player.original_oldbuttons;

      if (buttons & BT_ATTACK)
      {
         CheckCursorMovement((50, 25), 5, 5);
      }

      Super.Tick();
   }
}

This alternate example causes the VM to crash with a Fatal Error window. Might include more details soon.

Edit: Further investigation shows that this is, indeed, (just as I thought) compiler fuckery:
Image
More details soon maybe.
Attachments
JIT out vector2 Test_Alternate.pk3
(567 Bytes) Downloaded 3 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_
Github ID: Doom2fan
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

Re: [4.2.1] JIT crash with "out vector2" as parameter.

Postby dpJudas » Mon Oct 07, 2019 5:40 am

The check in the JIT is indeed one I added for sanity. It verifies that the input is what the code expects it to be. Either the input is invalid, or the code is based on assumptions that aren't always true. I assume its the former, but Graf should know for sure.
dpJudas
 
 
 
Joined: 28 May 2016

Re: [4.2.1] JIT crash with "out vector2" as parameter.

Postby phantombeta » Mon Oct 21, 2019 9:09 am

This is caused by a bug in the ZScript compiler Nevermind, I fucked up when debugging. Probably still a bug in the compiler, but not what I thought it was.
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_
Github ID: Doom2fan
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

Re: [4.2.1] JIT crash with "out vector2" as parameter.

Postby Major Cooke » Mon Oct 21, 2019 11:47 am

The problem lies with structs, and vectors are such (for those who don't know).

Code: Select allExpand view
bool CheckLine(out Line ln)
{
   if (ln == null)
      return false;
   return true;
}


If you pass in a null Line struct, it'll destroy the game with the null check. But it doesn't crash if it's not in/out.
User avatar
Major Cooke
Do unto others as you would have unto you. Judge yourself first.
 
Joined: 28 Jan 2007

Re: [4.2.1] JIT crash with "out vector2" as parameter.

Postby phantombeta » Mon Oct 21, 2019 12:05 pm

Major Cooke wrote:The problem lies with structs, and vectors are such (for those who don't know).
[...]
If you pass in a null Line struct, it'll destroy the game with the null check. But it doesn't crash if it's not in/out.

It's not really about being a struct, this is an issue that seems specific to vectors. The Line struct is also a native struct, which is always passed by pointer, not value, so it doesn't suffer from a lot of the problems "normal" structs do.
Also, please report that crash.
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_
Github ID: Doom2fan
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

Re: [4.2.1] JIT crash with "out vector2" as parameter.

Postby phantombeta » Mon Oct 21, 2019 2:39 pm

Fixed. This was caused by this bug, but vectors also had some hardcoded register offset code which had to be modified for this to actually work.
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_
Github ID: Doom2fan
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support


Return to Closed Bugs

Who is online

Users browsing this forum: Ahrefs [Bot] and 0 guests