This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug nss/19741] New: m68k: Assertion failure in gethostbyname
- From: "jrtc27 at jrtc27 dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Sun, 28 Feb 2016 14:09:34 +0000
- Subject: [Bug nss/19741] New: m68k: Assertion failure in gethostbyname
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=19741
Bug ID: 19741
Summary: m68k: Assertion failure in gethostbyname
Product: glibc
Version: 2.21
Status: NEW
Severity: normal
Priority: P2
Component: nss
Assignee: unassigned at sourceware dot org
Reporter: jrtc27 at jrtc27 dot com
Target Milestone: ---
It seems gethostbyname is broken, failing for me with
ânss_files/files-hosts.c:218: _nss_files_gethostbyname3_r: Assertion
`(bufferend - (char *) 0) % sizeof (char *) == 0' failed.â This can be
reproduced with the following simple program:
#include <stdio.h>
#include <netdb.h>
int main(int argc, char **argv) {
struct hostent *h = gethostbyname("localhost");
printf("name: %s\n", h->h_name);
return 0;
}
Delving inside glibc, _nss_files_gethostbyname3_r expects result->h_aliases to
be aligned to sizeof(char *), as can be seen in the assert (bufferend points to
an element in result->h_aliases, and each element is a char *). Provided this
is true when the function is called, it seems to correctly maintain the
invariant by rounding up bufferend when necessary.
However, the initial value of result->h_aliases is not aligned to sizeof(char
*). Instead, it is assigned in parse_list (nss_files/files-parse.c:245) and
aligned to __alignof__(char *). On many architectures, these are the same, but
on m68k, __alignof__(char *) == 2, but sizeof(char *) == 4. There may be
environments where result->h_aliases happens to be aligned to sizeof(char *) by
chance, but that is most certainly not the case on mine (latest unstable
running in ARAnyM).
I donât know why bufferend is required to be aligned to sizeof(char *), and
believe that imposing __alignof__(char *) in _nss_files_gethostbyname3_r
instead would suffice. Alternatively, parse_list could choose MAX(sizeof(char
*), __alignof__(char *)) as the alignment. Either way, the implementation as a
whole is currently broken.
--
You are receiving this mail because:
You are on the CC list for the bug.