[issue41883] ctypes pointee goes out of scope, then pointer in struct dangles and crashes

2020-09-30 Thread Ian M. Hoffman
Ian M. Hoffman added the comment: I agree with you. When I wrote "desired behavior" I intended it to mean "my selfishly desired outcome of not loading my struct with a dangling pointer." This issue seems to have descended into workarounds that treat the symptoms;

[issue41883] ctypes pointee goes out of scope, then pointer in struct dangles and crashes

2020-09-29 Thread Ian M. Hoffman
Ian M. Hoffman added the comment: You are correct. After further review, I found an older ctypes issue #12836 which was then enshrined in a workaround in the numpy.ndarray.ctypes interface to vanilla ctypes. https://numpy.org/doc/stable/reference/generated/numpy.ndarray.ctypes.html Numpy

[issue41883] ctypes pointee goes out of scope, then pointer in struct dangles and crashes

2020-09-28 Thread Ian M. Hoffman
New submission from Ian M. Hoffman : A description of the problem, complete example code for reproducing it, and a work-around are available on SO at the link: https://stackoverflow.com/questions/64083376/python-memory-corruption-after-successful-return-from-a-ctypes-foreign-function