New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ctypes: pass by value for structs broken on Cygwin/MinGW 64-bit #74538
Comments
The test ctypes.test.test_structures.StructureTestCase.test_pass_by_value fails on 64-bit Cygwin and MinGW using the system libffi with: ====================================================================== Traceback (most recent call last):
File "/home/embray/src/python/cpython/Lib/ctypes/test/test_structures.py", line 416, in test_pass_by_value
self.assertEqual(s.first, 0xdeadbeef)
AssertionError: 195948557 != 3735928559 It seems that libffi does not handle passing structs by value properly on those platforms as I explained here: libffi/libffi#305 The upstream bug hasn't been confirmed yet by the libffi developers so I could be wrong, but I think this is fairly clearly broken there. I have a PR forthcoming to work around the issue. |
Looks same as bpo-29804. |
Thanks for pointing that out. Indeed it's the same symptom, but slightly different cause. libffi has different implementations of its calling routines for different architectures/platforms depending on the machine architecture and calling conventions used. So this case is probably buggy for the arm64 implementation as well, as in bpo-29804. Off the top of my head I don't know a reliable way to check for this case, but this fix would work around the arm64 issue as well if I could check for that architecture easily at compile time. |
A 'defined(aarch64)' can be used for the arm64 arch. I will add it to your patch and test it on an arm64 machine to see if the test passes. |
I have added So could you please also add the check for |
Sure, thanks for pointing that out. |
Iryna, I updated the pull request with a slightly updated fix. Could you confirm again, when you get a chance, that it works for arm64? Thanks. |
Thank you, Erik. I have applied your new patch, and ran another build on arm64. The tests passed. Attaching the build log for more information. |
Thanks for checking! |
Patch LGTM now, perhaps others will concur? |
This bug affects also the 3.6 branch. Can the fix be backported? |
This has a backport PR now for 3.6. Once that PR is merged I think we can close this as fixed. |
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
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: