-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
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
test_ctypes.test_generated_structs.GeneratedTest.test_generated_data 'ManyTypesU' fails on Python 3.14 built with gcc 15 #128889
Comments
cc @encukou |
Note to self: test code in question is: https://github.com/python/cpython/blob/main/Lib/test/test_ctypes/test_generated_structs.py |
I was gonna report that the failures do not occur with Python 3.13 -- only to realize the tests do not exist there either. |
The failures in test_ctypes occurred for me on all archs I tried on (aarch64, ppc64le, s390x, x86_64) with gcc-15.0.0-0.2.fc42, from upstream gcc source 2024-12-03 revision d2b3fd44a4b20c573bb9c8ef5b17bdca70ea748b). Build logs are currently here: |
The package was built with 4 different configurations: "debug", "optimized", "freethreading-debug", "freethreading". Trying manually, test_ctypes succeeds with "optimized" and "freethreading", but fails with "debug" and "freethreading-debug". (the package build tries "debug" first in %check, and the failure there causes a fatal error of the package build without trying the other configs) |
Something I did locally has fixed it, FWIW I was trying to regenerate Modules/_ctypes/_ctypes_test_generated.c.h and somehow it now works for all 4 configurations. I'm not sure what I did that "fixed" it. |
Thanks for the report! I set some time aside for ctypes each week; I'll look into this soon. Thanks for the cc, Victor! @befeleme, you can mention me directly on anything ctypes related :) |
Hacking in some test prints and looking at the py_mem vs c_mem, it looks like the test is being over-zealous about the result. For example here:
...I see that the byte[0] is the same in both. In here, with ofs=0, size=2:
I see that bytes[0] and [1] are indeed the same in both. The docstring has this:
which perhaps GCC 15 isn't doing in some cases (not sure; haven't reliably reproduced this). |
Possibly relates to this new GCC 15 optimization: expr, c: Don't clear whole unions relating to GCC bug 116416. If so (though I haven't proven this), a workaround might be to use |
Yes: if I recompile
|
Note that See: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fzero-init-padding-bits_003dvalue |
I tried reproducing using the @davidmalcolm or @befeleme, could you test with #128944? Looks like a memset should solve this case.
Thanks! Yeah, I'm aware the tests don't play by the book. I'm (slowly) adding infrastructure to make them better. The test writes a struct field, in both Python/ctypes and in C, and checks that the operation has the same result. |
I built Python manually on Fedora Rawhide (in mock) but I failed to reproduce the test_ctypes failure. I tested gcc (GCC) 15.0.1 20250114 (Red Hat 15.0.1-0) and built Python with:
|
Oh ok, I managed to reproduce the issue: Python must be built with
|
Bug report
Bug description:
When running test suite on Python 3.14.0a4 built with gcc 15.0.3 on Fedora Linux 42 (Rawhide), test_generated_data fails for many of its types.
I suspect this is due to the new gcc version. This doesn't happen when Python is built with gcc 14.
CPython versions tested on:
3.14
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: