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

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
Guest

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

Post by Guest »

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

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

Post by phantombeta »

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 all

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 126 times
dpJudas
 
 
Posts: 3040
Joined: Sat May 28, 2016 1:01 pm

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

Post by dpJudas »

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

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

Post by phantombeta »

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
Major Cooke
Posts: 8175
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

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

Post by Major Cooke »

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

Code: Select all

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

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

Post by phantombeta »

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

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

Post by phantombeta »

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.
Post Reply

Return to “Closed Bugs [GZDoom]”