tech-pkg archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
py-cares structure packing woes (cffi)
Home Assistant requires py-cares, and now it's throwing errors at
startup:
Exception ignored from cffi callback <function _addrinfo_cb at 0x7c8bbf123f70>:
Traceback (most recent call last):
File "/var/hass/HASS312/lib/python3.12/site-packages/pycares/__init__.py", line 162, in _addrinfo_cb
result = ares_addrinfo_result(res)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/hass/HASS312/lib/python3.12/site-packages/pycares/__init__.py", line 847, in __init__
self.nodes.append(ares_addrinfo_node_result(node_ptr))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/hass/HASS312/lib/python3.12/site-packages/pycares/__init__.py", line 813, in __init__
if _ffi.NULL != _lib.ares_inet_ntop(s.sin_family, _ffi.addressof(s.sin_addr), ip, _lib.INET6_ADDRSTRLEN):
^^^^^^^^^^^^
ffi.error: struct in_addr: wrong total alignment (cdef says 4, but C compiler says 1). fix it or use "...;" as the last field in the cdef for struct in_addr to make it flexible
I can reproduce this, more or less, by running tests under py-cares, so
it's not that our module is ok and using pip isn't.
It turns out the cffi def is
struct in_addr {
uint32_t s_addr;
};
while the NetBSD 9 /usr/include/netinet/in.h definition is:
struct in_addr {
in_addr_t s_addr;
} __packed;
and yes in_addr_t is uint32_t.
The __packed attribute tells the compiler that the 32-bit in need only
be aligned to 1 byte.
This explains the error, more or less.
It would seem that the right thing is to split the cdef so that this can
be marked packed. Or perhaps to add the ... to the cdef as suggested,
but that runs into trouble.
Our sources seem to call this packed since:
revision 1.43
date: 1999-11-19 19:37:59 -0500; author: thorpej; state: Exp; lines: +2 -2;
Add the `packed' attribute to structures which describe wire protocol data.
with a change in packed expression in 2007 by perry.
Does anybody understand if this is new/newish cffi behavior? Is this
error helpful? What kind of changes should we make? Are they about
pkgsrc, or fixing py-cares for NetBSD? For more than NetBSD?
Home |
Main Index |
Thread Index |
Old Index