For some time, we see various unaligned exceptions running apt-get on hppa: http(13559): unaligned access to 0x00000000fa703d49 at ip=0x00000000f9f0a9bb handle_unaligned: 37 callbacks suppressed http(13810): unaligned access to 0x00000000fa703d49 at ip=0x00000000f9f0a9bb http(13810): unaligned access to 0x00000000fa703d49 at ip=0x00000000f9f0a9c3 http(13810): unaligned access to 0x00000000fa703d49 at ip=0x00000000f9f0cdf3 http(13810): unaligned access to 0x00000000fa703d49 at ip=0x00000000f9f0cecf http(13810): unaligned access to 0x00000000fa703d4d at ip=0x00000000f9f0c69b Helge and myself tracked the first of these exceptions to the following line in res_query.c: hp->rcode = NOERROR; /* default */ The argument answer has the type u_char *. Thus, the function __libc_res_nquery should nominally be prepared to access the HEADER struct on a byte boundary. However, the struct HEADER is not defined with the packed attribute, so accesses to the bit fields in the struct are done with word rather than byte accesses. This causes the above faults. This is very inefficient on strict alignment targets such as hppa and ia64, and slow on x86, etc. Adding "__attribute__((packed))" to the HEADER typedef appears to eliminate the unaligned accesses from http.
Patch here: https://sourceware.org/ml/libc-alpha/2016-06/msg00581.html
New patch here: https://sourceware.org/ml/libc-alpha/2016-06/msg00679.html
New patch is here: https://sourceware.org/ml/libc-alpha/2016-06/msg01020.html
Did this ever get landed? https://sourceware.org/legacy-ml/libc-alpha/2016-06/msg01020.html
On 2022-01-30 10:29 p.m., sam at gentoo dot org wrote: > Did this ever get landed? No but Debian has been carrying it for some time.
(In reply to dave.anglin from comment #5) > On 2022-01-30 10:29 p.m., sam at gentoo dot org wrote: > > Did this ever get landed? > No but Debian has been carrying it for some time. I spoke to azanella and we agreed the patch seems reasonable: [17:44:45] <azanella> sam_, this has triggered an issue with or1k recently https://patchwork.sourceware.org/project/glibc/patch/20210614234011.2215641-1-shorne@gmail.com/ and I think the latest patch from david should be ok (although I am not very found of the packet usage) [17:52:21] <sam_> oh I'd missed that one [18:03:55] <sam_> are you able to apply it or do I need to ask david to do it? [18:09:35] <azanella> sam_, could you please ask sam to repost it, so we can proper review it? [18:39:27] <sam_> azanella: ofc, will do Could you resend it to libc-alpha and then we can get this in?
On 2022-03-14 2:40 p.m., sam at gentoo dot org wrote: > Could you resend it to libc-alpha and then we can get this in? Will do after recheck on master.
Patch v4 here: https://sourceware.org/pipermail/libc-alpha/2022-March/137164.html
commit 05dec22d7be722987ff07aebf9690f6078b3c4e9 (HEAD -> master, origin/master, origin/HEAD) Author: John David Anglin <danglin@gcc.gnu.org> Date: Tue Mar 22 17:35:54 2022 +0000 resolv: Fix unaligned accesses to fields in HEADER struct The structure HEADER is normally aligned to a word boundary but sometimes it needs to be accessed when aligned on a byte boundary. This change defines a new typedef, UHEADER, with alignment 1. It is used to ensure the fields are accessed with byte loads and stores when necessary. V4: Change to res_mkquery.c deleted. Small whitespace fix. V5: Move UHEADER typedef to resolv/resolv-internal.h. Replace all HEADER usage with UHEADER in resolv/res_send.c. Signed-off-by: John David Anglin <dave.anglin@bell.net> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>