This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author taralx
Recipients taralx
Date 2022-03-09.02:28:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1646792883.64.0.681602765886.issue46966@roundup.psfhosted.org>
In-reply-to
Content
The following code will likely crash on I32LP64 systems:

dim = lib.get_array_size(opaque)
ptrs = (c_void_p * dim)()
lib.get_array_values(opaque, ptrs)
for ptr in ptrs:
    print(lib.get_object_value(ptr))

What happens is that `ptr` is not a `c_void_p` -- it's just a bare number. And when it's passed to another function it goes in as a (32-bit) `c_int`, resulting in a truncation.

I'm not sure what can be done here (maybe a truncation warning?) but it's definitely a difficult bug to notice when reviewing code.
History
Date User Action Args
2022-03-09 02:28:03taralxsetrecipients: + taralx
2022-03-09 02:28:03taralxsetmessageid: <1646792883.64.0.681602765886.issue46966@roundup.psfhosted.org>
2022-03-09 02:28:03taralxlinkissue46966 messages
2022-03-09 02:28:03taralxcreate