This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]