Native/scripting struct size mismatch

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
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Native/scripting struct size mismatch

Post by _mental_ »

There is a potential size mismatch between C++ and ZScript structures.
It's caused by tail padding of native structures that isn't taken into account when calculating object sizes for scripting side.

So far, FLineTraceData is certainly affected by this issue. It's native size is 120 bytes (Visual Studio, x64 target) while ZScript assumes 116 bytes only.
As the result, this line overwrites four bytes that are not belonging to an instance of FLineTraceData.
Spoiler: Samples
It seems we have no way to declare relation between such native and scripting definitions.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49072
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Native/scripting struct size mismatch

Post by Graf Zahl »

It looks like FLineTraceData was not properly declared. For natively backed structs, all member variables need to be native and the whole thing must be set up manually in InitThingdef to eliminate these compiler deprendencies. Look how FCheckPosition, which is right above in the script source, was done, this is the correct way to implement it.
User avatar
Marisa the Magician
Posts: 3886
Joined: Fri Feb 08, 2008 9:15 am
Preferred Pronouns: She/Her
Operating System Version (Optional): (btw I use) Arch
Graphics Processor: nVidia with Vulkan support
Location: Vigo, Galicia
Contact:

Re: Native/scripting struct size mismatch

Post by Marisa the Magician »

My fault, I guess.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Native/scripting struct size mismatch

Post by _mental_ »

Fixed in f46e80e.
Post Reply

Return to “Closed Bugs [GZDoom]”