From: Willy Tarreau <w@1wt.eu>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] tools/nolibc: use __builtin_offsetof()
Date: Sat, 4 Apr 2026 10:34:24 +0200 [thread overview]
Message-ID: <adDNEEmZrqi-IiYp@1wt.eu> (raw)
In-Reply-To: <20260401-nolibc-asprintf-v1-1-46292313439f@weissschuh.net>
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@1wt.eu>
thanks,
Willy
next prev parent reply other threads:[~2026-04-04 8:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-01 15:07 [PATCH 0/3] tools/nolibc: add support for asprintf() Thomas Weißschuh
2026-04-01 15:07 ` [PATCH 1/3] tools/nolibc: use __builtin_offsetof() Thomas Weißschuh
2026-04-04 8:34 ` Willy Tarreau [this message]
2026-04-04 15:29 ` David Laight
2026-04-01 15:07 ` [PATCH 2/3] selftests/nolibc: test the memory allocator Thomas Weißschuh
2026-04-04 8:51 ` Willy Tarreau
2026-04-01 15:07 ` [PATCH 3/3] tools/nolibc: add support for asprintf() Thomas Weißschuh
2026-04-04 8:53 ` Willy Tarreau
2026-04-04 15:34 ` David Laight
2026-04-05 15:39 ` Thomas Weißschuh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=adDNEEmZrqi-IiYp@1wt.eu \
--to=w@1wt.eu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox