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.

classification
Title: ctypes: Heap Pointer is damaged between C and Python
Type: Stage: resolved
Components: Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: canberk.sonmez.409, eric.smith
Priority: normal Keywords:

Created on 2021-03-19 18:19 by canberk.sonmez.409, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg389107 - (view) Author: Canberk Sönmez (canberk.sonmez.409) Date: 2021-03-19 18:19
Please see the SO post:

https://stackoverflow.com/questions/66713071/ctypes-heap-pointer-is-damaged-between-c-and-python-linux-x86-64

In summary, when I return a pointer to a heap-allocated memory location from a C function, its most significant 32 bits are chopped off for some reason.

I observed this behavior in Python 3.7 and Python 3.8, on Ubuntu 18.04 and Centos 7 (x86_64).
msg389109 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2021-03-19 18:40
Are you using a 64-bit version of python? What is sys.maxsize?
msg389110 - (view) Author: Canberk Sönmez (canberk.sonmez.409) Date: 2021-03-19 18:47
Alright, I solved the problem. It was simply a typo: "restypes" instead of "res_types". It didn't cause a problem in Python 3.6 but obviously, something was changed. A nice error message might be nice when setting these attributes.
History
Date User Action Args
2022-04-11 14:59:43adminsetgithub: 87725
2021-03-19 18:47:37canberk.sonmez.409setstatus: open -> closed
resolution: not a bug
messages: + msg389110

stage: resolved
2021-03-19 18:40:01eric.smithsetnosy: + eric.smith
messages: + msg389109
2021-03-19 18:19:33canberk.sonmez.409create