[RFC][BZ #16549] Add sanity check for condvar alignment.

Carlos O'Donell carlos@redhat.com
Sat Apr 12 00:45:00 GMT 2014


On 02/11/2014 01:05 PM, Roland McGrath wrote:
>> On Tue, Feb 11, 2014 at 09:21:11AM -0800, Roland McGrath wrote:
>>>> +  assert (((uintptr_t) cond) % sizeof (long) == 0);
>>>
>>> Drop superfluous parens.  Use __alignof (pthread_cond_t).
>>
>> OK now?
>>
>> 	* nptl/pthread_cond_init.c (__pthread_cond_init): Add assert that
>> 	input is aligned.
> 
> Looks fine.

Except that this is an assert on user provided structures that violates
the API and is therefore undefined behaviour.

See:
https://sourceware.org/glibc/wiki/Style_and_Conventions#Assertions

This kind of checking should be delegated to static analysis tools.
I agree with the rest of the thread that this assert should not be
added to this code.

My request for Torvald to add an assert to the fork generation counter
is an *internal* consistency check to ensure we don't overflow the
counter and a valid use of an assert IMO.

Cheers,
Carlos.



More information about the Libc-alpha mailing list