This is the mail archive of the
mailing list for the glibc project.
Re: [RFC][BZ #16549] Add sanity check for condvar alignment.
- From: "Carlos O'Donell" <carlos at redhat dot com>
- To: Roland McGrath <roland at hack dot frob dot com>, OndÅej BÃlka <neleai at seznam dot cz>
- Cc: libc-alpha at sourceware dot org, Torvald Riegel <triegel at redhat dot com>, Rich Felker <dalias at aerifal dot cx>
- Date: Fri, 11 Apr 2014 20:45:32 -0400
- Subject: Re: [RFC][BZ #16549] Add sanity check for condvar alignment.
- Authentication-results: sourceware.org; auth=none
- References: <20140211124346 dot GA31165 at domone dot podge> <20140211172111 dot 5827B74451 at topped-with-meat dot com> <20140211175741 dot GA32451 at domone dot podge> <20140211180520 dot 7C64174448 at topped-with-meat dot com>
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.
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.