Re: [PATCH 1/3] tools/nolibc: use __builtin_offsetof()
From: Willy Tarreau
Date: Sat Apr 04 2026 - 04:34:34 EST
Hi Thomas,
On Wed, Apr 01, 2026 at 05:07:27PM +0200, Thomas Weißschuh wrote:
> The current custom implementation of offsetof() fails UBSAN:
> runtime error: member access within null pointer of type 'struct ...'
> This means that all its users, including container_of(), free() and
> realloc(), fail.
>
> Use __builtin_offsetof() instead which does not have this issue and
> has been available since GCC 4 and clang 4.
Yeah, that's a place where I find the standard ambiguous and ridiculously
absurd (since there's no dereference, only an address calculations), but I
had to do the same in haproxy recently for the same reasons, and I didn't
remember that we had it in nolibc as well. So that's an obvious ack!
Acked-by: Willy Tarreau <w@xxxxxx>
thanks,
Willy