[PATCH] malloc: fix undefined behavior in obstack.h [BZ #32393]

Sam James sam@gentoo.org
Thu May 8 09:52:44 GMT 2025


Sam James <sam@gentoo.org> writes:

> Paul Eggert <eggert@cs.ucla.edu> writes:
>
>> On 2025-04-28 20:39, Collin Funk wrote:
>>
>>> +# define PTR_UINT_TYPE __UINTPTR_TYPE__
>>
>> Let's call this new macro __PTR_UINT_TYPE instead, to avoid namespace
>> pollution.
>>
>>
>>> +#define __PTR_ALIGN(B, P, A) \
>>> +  (sizeof (PTR_INT_TYPE) < sizeof (void *) \
>>> +   ? (B) + (((P) - (B) + (A)) & ~(A))      \
>>> +   : (P) + ((- (PTR_UINT_TYPE) (P)) & (A)))
>>
>> This collides with Gnulib, which needs to do this a different way to
>> avoid a compiler error with Oracle Developer Studio. Although
>> admittedly it'll take a bit of work to merge with Gnulib, let's not
>> make merging harder.
>>
>> How about the attached patch instead?
>
> I have something similar in a local copy of a sync for gcc I haven't
> finished off:
>
> Reviewed-by: Sam James <sam@gentoo.org>
>
> (but I think Collin's was fine too, just your point is fair about not
> making it harder to sync.)

Paul, do you plan on pushing this? I'd like to backport it to the
branches in due course. I've seen you're working on reducing the
divergence on the gnulib side but a larger sync wouldn't be backportable
(at least not without more discussion).

>
>>
>> [2. text/x-patch; 0001-malloc-fix-undefined-behavior-in-obstack.h-BZ-32393.patch]...


More information about the Libc-alpha mailing list