Issue34603
Created on 2018-09-07 11:15 by mattneri, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| MarshallingTest.zip | mattneri, 2018-09-07 11:15 | |||
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 9258 | merged | v2m, 2018-09-13 15:43 | |
| PR 9340 | merged | miss-islington, 2018-09-16 05:36 | |
| PR 9341 | merged | miss-islington, 2018-09-16 05:36 | |
| PR 9342 | closed | miss-islington, 2018-09-16 05:37 | |
| PR 9425 | merged | v2m, 2018-09-19 18:48 | |
| PR 9721 | merged | serhiy.storchaka, 2018-10-05 17:52 | |
| PR 9725 | merged | serhiy.storchaka, 2018-10-05 18:16 | |
| PR 9727 | merged | miss-islington, 2018-10-05 18:46 | |
| Messages (11) | |||
|---|---|---|---|
| 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 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:05 | admin | set | github: 78784 |
| 2018-10-05 19:11:26 | serhiy.storchaka | set | messages: + msg327175 |
| 2018-10-05 18:46:36 | miss-islington | set | pull_requests: + pull_request9112 |
| 2018-10-05 18:46:29 | serhiy.storchaka | set | messages: + msg327170 |
| 2018-10-05 18:16:26 | serhiy.storchaka | set | pull_requests: + pull_request9110 |
| 2018-10-05 18:10:02 | serhiy.storchaka | set | messages: + msg327161 |
| 2018-10-05 18:09:03 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages: + msg327159 |
| 2018-10-05 17:52:10 | serhiy.storchaka | set | pull_requests: + pull_request9106 |
| 2018-09-19 20:49:26 | vstinner | set | status: open -> closed resolution: fixed messages: + msg325801 stage: patch review -> resolved |
| 2018-09-19 20:48:26 | vstinner | set | messages: + msg325800 |
| 2018-09-19 18:48:45 | v2m | set | pull_requests: + pull_request8843 |
| 2018-09-16 05:57:49 | miss-islington | set | messages: + msg325473 |
| 2018-09-16 05:53:16 | miss-islington | set | nosy:
+ miss-islington messages: + msg325472 |
| 2018-09-16 05:37:04 | miss-islington | set | pull_requests: + pull_request8766 |
| 2018-09-16 05:36:53 | miss-islington | set | pull_requests: + pull_request8765 |
| 2018-09-16 05:36:45 | miss-islington | set | pull_requests: + pull_request8764 |
| 2018-09-16 05:36:33 | vstinner | set | nosy:
+ vstinner messages: + msg325471 |
| 2018-09-13 15:43:43 | v2m | set | keywords:
+ patch stage: patch review pull_requests: + pull_request8690 |
| 2018-09-12 23:03:18 | v2m | set | nosy:
+ v2m messages: + msg325207 |
| 2018-09-10 07:50:25 | mattneri | set | nosy:
+ amaury.forgeotdarc, belopolsky, meador.inge |
| 2018-09-07 11:25:52 | mattneri | set | title: ctypes On Windows: error calling C function that returns a struc containing 3 bools -> ctypes on Windows: error calling C function that returns a struct containing 3 bools |
| 2018-09-07 11:15:17 | mattneri | create | |