Skip to content

Struct (union) offsets are wrong #194

Description

@andrew-boyarshin

Noticed when manually reviewing Vortice.MediaFoundation bindings. MFTOPONODE_ATTRIBUTE_UPDATE is an example of a wrong structure. cfa2b3b adds a repro, without a fix. Union fields are supposed to all have an offset of 32, but the first member of a union (u32) is generated to have an offset of 28, which will lead to incorrectly behaving bindings.
Most likely StructTransform is not robust enough, and I'm not sure why union is aligned to 8 byte boundary, instead of traditional 4. This will require investigation into struct layout ABIs.
This is confirmed not to be a regression from 2.0.0-beta.7 to 2.0.0-beta.8.

public override void Process(CsStruct csStruct)
{
// TODO: this mapping must be robust. Current calculation for field offset is not always accurate for union.
// TODO: need to handle align/packing correctly.

FYI, @amerkoleci.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions