[krbdev.mit.edu #9283] configure: gethostbyname_r return-type checks fail under C23 (gcc 15), causing non-reentrant gethostbyname() use on musl

Will Hicks via RT rt-comment at krbdev.mit.edu
Wed Nov 11 02:04:18 EST 2026


Wed Nov 11 02:04:18 2026: Request 9283 was acted upon.
 Transaction: Ticket created by will.hicks at blackline.com
       Queue: krb5
     Subject: configure: gethostbyname_r return-type checks fail under C23 (gcc 15), causing non-reentrant gethostbyname() use on musl
       Owner: Nobody
  Requestors: will.hicks at blackline.com
      Status: new
 Ticket <URL: https://krbdev.mit.edu/rt/Ticket/Display.html?id=9283 >


The gethostbyname_r return-type tests in src/configure.ac declare the
function with an empty parameter list:

    #include <netdb.h>
    extern int gethostbyname_r();
    ...
    extern struct hostent *gethostbyname_r();

In C23 (gcc 15's default, -std=gnu23), "()" means "no parameters", so
both declarations conflict with the real prototype in <netdb.h> and
fail to compile. configure then reports "cannot determine return type
of gethostbyname_r -- disabling", and HAVE_GETHOSTBYNAME_R is left
undefined.

On musl, src/util/support/fake-addrinfo.c also defines
COPY_FIRST_CANONNAME (since __GLIBC_PREREQ is not available), and the
getaddrinfo wrapper falls back to the non-reentrant gethostbyname().
When several threads call gss_init_sec_context() at once, the shared
hostent result is freed twice, and musl's allocator aborts the process
(SIGSEGV).

- Observed with krb5 1.22.1 on Alpine Linux 3.23 (gcc 15, musl 1.2.5).
- The same check appears unchanged in 1.22.3 and on master.
- The Alpine 3.22 build of 1.21.3, compiled with gcc 14 / C17, is not
  affected.
- glibc builds don't take this code path.

Suggested fix: declare full prototypes in the test programs, matching
the glibc and Solaris signatures, or detect the return type with a test
that doesn't rely on unprototyped declarations.

Downstream reports:
https://gitlab.alpinelinux.org/alpine/aports/-/work_items/18185
https://github.com/dotnet/runtime/issues/123782
https://github.com/home-operations/containers/pull/2113



More information about the krb5-bugs mailing list