NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/60150: named(8) crashes at startup on NetBSD/i386 11.0_RC2
The following reply was made to PR bin/60150; it has been noted by GNATS.
From: RVP <rvp%SDF.ORG@localhost>
To: Izumi Tsutsui <tsutsui%ceres.dti.ne.jp@localhost>
Cc: gnats-bugs%netbsd.org@localhost
Subject: Re: bin/60150: named(8) crashes at startup on NetBSD/i386 11.0_RC2
Date: Sun, 5 Apr 2026 10:51:36 +0000 (UTC)
On Sat, 4 Apr 2026, Izumi Tsutsui wrote:
> On NetBSD/i386, sizeof(max_align_t) is 12 bytes so
> sizeof(union size_info) is also 12 byets.
>
Yes, and `alignof(max_align_t)' is 4 which'll also stomp on the flag bits
encoded in the lowest 3 bits of the pointer address.
> The returned addess of mallocx() calculated by `ptr = &si[1];`
> is not 8 byte aligned.
>
Yes, it _must_ be at least 8-byte aligned, but on NetBSD/i386, as we've seen,
it isn't. Don't know what the reasoning behind the `max_align_t __alignment;'
there is. The usual way, if the pointer immediately following, should also be
aligned, is to do `alignas(max_align_t) ...' but this requires a C11 compiler.
In any case, someone should definitely ask the BIND people.
> Actually the following ugly patch fixes the assertion of _cds_lfht_add()
> in liburcu:
>
> ---
> Index: dist/lib/isc/jemalloc_shim.h
> ===================================================================
> RCS file: /cvsroot/src/external/mpl/bind/dist/lib/isc/jemalloc_shim.h,v
> retrieving revision 1.4
> diff -u -p -d -r1.4 jemalloc_shim.h
> --- dist/lib/isc/jemalloc_shim.h 26 Jan 2025 16:25:37 -0000 1.4
> +++ dist/lib/isc/jemalloc_shim.h 3 Apr 2026 20:13:47 -0000
> @@ -30,9 +30,17 @@ const char *malloc_conf = NULL;
>
> #include <stdlib.h>
>
> +#ifndef ALIGNMENT
> +#define ALIGNMENT 8U
> +#endif
> +#ifndef roundup2
> +#define roundup2(x,m) ((((x) - 1) | ((m) - 1)) + 1)
> +#endif
> +
> typedef union {
> size_t size;
> max_align_t __alignment;
> + uint8_t __roundup[roundup2(sizeof(max_align_t), ALIGNMENT)];
> } size_info;
>
> static inline void *
>
I've fixed it slightly differently:
```
--- src/external/mpl/bind/dist/lib/isc/jemalloc_shim.h.orig 2025-01-26 16:25:37.000000000 +0000
+++ src/external/mpl/bind/dist/lib/isc/jemalloc_shim.h 2026-04-05 10:29:53.567824881 +0000
@@ -32,7 +32,16 @@
typedef union {
size_t size;
- max_align_t __alignment;
+ /*
+ * should be `alignas(max_align_t) char __alignment;', but this,
+ * using NetBSD's stddef.h, yields a 4-byte alignment (16 if you
+ * use GCC's own stddef.h).
+ *
+ * Remove uncertainty by explicitly padding to 16 bytes, ie. malloc(3)
+ * alignment. (Actually, the pointer following this header need only
+ * be 8-byte aligned.)
+ */
+ char __alignment[16];
} size_info;
static inline void *
```
HTH,
-RVP
Home |
Main Index |
Thread Index |
Old Index