[Fixed] Native/scripting struct size mismatch

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Native/scripting struct size mismatch

Postby _mental_ » Wed Mar 11, 2020 4:59 am

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

Re: Native/scripting struct size mismatch

Postby Graf Zahl » Wed Mar 11, 2020 5:44 am

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

Re: Native/scripting struct size mismatch

Postby Marisa Kirisame » Wed Mar 11, 2020 3:34 pm

My fault, I guess.
User avatar
Marisa Kirisame
ZScript Crimester
Joined: 08 Feb 2008
Location: Vigo, Galicia
Discord: 霧雨魔理沙#1666
Twitch ID: magusmarisa
Github ID: OrdinaryMagician
Operating System: Other Linux 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Native/scripting struct size mismatch

Postby _mental_ » Sat Mar 14, 2020 4:59 am

Fixed in f46e80e.
Joined: 07 Aug 2011

Return to Closed Bugs

Who is online

Users browsing this forum: No registered users and 3 guests