msg324732 - (view) |
Author: MatteoL (mattneri) |
Date: 2018-09-07 11:15 |
Marshalling the following C structure with ctypes in Windows (compiled with VS2015) is not working correctly. As you can see, in the simple demo program I attached, the integer I pass as a parameter gets somehow corrupted. I use cdecl calling convention. The corruption happens only if the returned structure contains 3 booleans, if I add a fourth bool to the structure than I get expected results. In linux (compiling with Gcc) the same code (with 3 booleans) work as expected. typedef uint64_t CustomHandle; typedef struct { bool first; bool second; bool third; } Flags; CustomHandle GetHandle(); Flags GetFlags(CustomHandle handle); As already mention I attached all the files to reproduce the issue with the related cmake file |
|
|
msg325207 - (view) |
Author: Vladimir Matveev (v2m) * |
Date: 2018-09-12 23:03 |
I think the problem is that FFI layer assumes that MSVC compiler will try to pass any structure less than 8 bytes in registers whereis it is not always true: To be returned by value in RAX, user-defined types must have a length of 1, 2, 4, 8, 16, 32, or 64 bits (from https://msdn.microsoft.com/en-us/library/7572ztz4.aspx). I have a fix, now adding tests. |
|
|
msg325471 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2018-09-16 05:36 |
New changeset 7843caeb909bd907e903606414e238db4082315a by Victor Stinner (Vladimir Matveev) in branch 'master': bpo-34603, ctypes/libffi_msvc: Fix returning structs from functions (GH-9258) https://github.com/python/cpython/commit/7843caeb909bd907e903606414e238db4082315a |
|
|
msg325472 - (view) |
Author: miss-islington (miss-islington) |
Date: 2018-09-16 05:53 |
New changeset e3f6aa7fe48b91f4ff619b2a51d473249d620bcb by Miss Islington (bot) in branch '3.7': bpo-34603, ctypes/libffi_msvc: Fix returning structs from functions (GH-9258) https://github.com/python/cpython/commit/e3f6aa7fe48b91f4ff619b2a51d473249d620bcb |
|
|
msg325473 - (view) |
Author: miss-islington (miss-islington) |
Date: 2018-09-16 05:57 |
New changeset e53632019816749ffd5be0afab2a99d744dbbe35 by Miss Islington (bot) in branch '3.6': bpo-34603, ctypes/libffi_msvc: Fix returning structs from functions (GH-9258) https://github.com/python/cpython/commit/e53632019816749ffd5be0afab2a99d744dbbe35 |
|
|
msg325800 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2018-09-19 20:48 |
New changeset b63a16febbd1c943c9dbc5c651326b410aa50698 by Victor Stinner (Vladimir Matveev) in branch '2.7': [2.7] bpo-34603, ctypes/libffi_msvc: Fix returning structs from functions (GH-9258) (GH-9425) https://github.com/python/cpython/commit/b63a16febbd1c943c9dbc5c651326b410aa50698 |
|
|
msg325801 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2018-09-19 20:49 |
Thanks MatteoL for the bug report, it has been fixed in 2.7, 3.6, 3.7 and master. Thanks Vladimir Matveev for the fix! |
|
|
msg327159 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2018-10-05 18:09 |
assertEquals() is deprecated, use assertEqual() instead. |
|
|
msg327161 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2018-10-05 18:10 |
New changeset 4642d5f59828e774585e9895b538b24d71b9df8e by Serhiy Storchaka in branch 'master': Use assertEqual() instead of assertEquals(). (GH-9721) https://github.com/python/cpython/commit/4642d5f59828e774585e9895b538b24d71b9df8e |
|
|
msg327170 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2018-10-05 18:46 |
New changeset 6bffe50f5fff8e8a40ae32c3e9c408622a15caf6 by Serhiy Storchaka in branch '3.7': Use assertEqual() instead of assertEquals(). (GH-9721) (GH-9725) https://github.com/python/cpython/commit/6bffe50f5fff8e8a40ae32c3e9c408622a15caf6 |
|
|
msg327175 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2018-10-05 19:11 |
New changeset d02490a9a9c238ed7ded1120877fdfdce16364a3 by Serhiy Storchaka (Miss Islington (bot)) in branch '3.6': Use assertEqual() instead of assertEquals(). (GH-9721) (GH-9725) (GH-9727) https://github.com/python/cpython/commit/d02490a9a9c238ed7ded1120877fdfdce16364a3 |
|
|