Native/scripting struct size mismatch

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 a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Native/scripting struct size mismatch

Re: Native/scripting struct size mismatch

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

Fixed in f46e80e.

Re: Native/scripting struct size mismatch

by Marisa the Magician » Wed Mar 11, 2020 3:34 pm

My fault, I guess.

Re: Native/scripting struct size mismatch

by 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.

Native/scripting struct size mismatch

by _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.

Top