ctypes on Windows: error calling C function that returns a struct containing 3 bools #78784
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
assignee = None closed_at = <Date 2018-09-19.20:49:26.494> created_at = <Date 2018-09-07.11:15:17.826> labels = ['ctypes', 'type-bug', '3.7'] title = 'ctypes on Windows: error calling C function that returns a struct containing 3 bools' updated_at = <Date 2018-10-05.19:11:26.672> user = 'https://bugs.python.org/mattneri'
activity = <Date 2018-10-05.19:11:26.672> actor = 'serhiy.storchaka' assignee = 'none' closed = True closed_date = <Date 2018-09-19.20:49:26.494> closer = 'vstinner' components = ['ctypes'] creation = <Date 2018-09-07.11:15:17.826> creator = 'mattneri' dependencies =  files = ['47789'] hgrepos =  issue_num = 34603 keywords = ['patch'] message_count = 11.0 messages = ['324732', '325207', '325471', '325472', '325473', '325800', '325801', '327159', '327161', '327170', '327175'] nosy_count = 8.0 nosy_names = ['amaury.forgeotdarc', 'belopolsky', 'vstinner', 'meador.inge', 'serhiy.storchaka', 'miss-islington', 'v2m', 'mattneri'] pr_nums = ['9258', '9340', '9341', '9342', '9425', '9721', '9725', '9727'] priority = 'normal' resolution = 'fixed' stage = 'resolved' status = 'closed' superseder = None type = 'behavior' url = 'https://bugs.python.org/issue34603' versions = ['Python 3.4', 'Python 3.5', 'Python 3.6', 'Python 3.7']
The text was updated successfully, but these errors were encountered:
Marshalling the following C structure with ctypes in Windows (compiled with VS2015) is not working correctly.
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;
As already mention I attached all the files to reproduce the issue with the related cmake file
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: