Skip to content

Bug: c_uint64 struct fields corrupted when value >= 2^63 #52

@sjalloq

Description

@sjalloq

I've been trying to get a basic example working and have hit a bug in gen_sv_class.py. It uses PyLong_AsLong() for c_uint64 fields when it should be using PyLong_AsUnsignedLongLong().

Any ctypes.Structure with a c_uint64 field set to a value >= 0x8000000000000000 causes the value to wrap. The struct_passing example doesn't hit this because it uses small values.

This possibly also affects: c_uint32 (line 1005) and c_uint16 (line 1003) which could have the same issue at their respective sign boundaries, though c_uint32 is cast via 32'() from a 64-bit signed value so it may accidentally work for values < 2^32.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions