You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found one issue related to bitfields and ctypes, and although there is a similar issue already opened (https://bugs.python.org/issue29753), that only covers the case with pragmas.
I tried to debug a little bit, adding some prints before and after calling *PyCField_FromDesc* in *Modules/_ctypes/stgdict.c:L603*.=, if someone wants to look at it, the logs are attached / one log file per each test, using the following gdb init:
# before
break stgdict.c:601
commands
p field_size
p bitofs
p size
p align
p *dict
continue
end
# after
break stgdict.c:617
commands
p field_size
p bitofs
p size
p align
p *(CFieldObject*) prop
continue
end
Hope someone could spot the issue, I will also try to investigate it by my own.
Activity
berthin commentedon Oct 4, 2020
Hi all,
I found one issue related to bitfields and ctypes, and although there is a similar issue already opened (https://bugs.python.org/issue29753), that only covers the case with pragmas.
Please, consider the following scenario:
Which seems to be incorrect, because what natively C does is to generate a 4bytes struct.
root@0bc6a647abaa:/target/cpython-fix# cat sample.c
root@0bc6a647abaa:/target/cpython-fix# gcc sample.c -o a && ./a
4
Also, if I use different databtypes I get what I expect (a struct of 4 bytes).
I tried to debug a little bit, adding some prints before and after calling *PyCField_FromDesc* in *Modules/_ctypes/stgdict.c:L603*.=, if someone wants to look at it, the logs are attached / one log file per each test, using the following gdb init:
# before
break stgdict.c:601
commands
p field_size
p bitofs
p size
p align
p *dict
continue
end
# after
break stgdict.c:617
commands
p field_size
p bitofs
p size
p align
p *(CFieldObject*) prop
continue
end
Hope someone could spot the issue, I will also try to investigate it by my own.
Best,
P.S. For the tests, I worked on top of bpo-29753 (#19850)
encukou commentedon Sep 10, 2024
Fixed in #97702, the reproducer is now part of tests (as the
Example_gh_86098*classes)