Implement checking for pthread_join

Jakub Jelinek jakub@redhat.com
Fri Jan 4 14:34:00 GMT 2008


On Fri, Jan 04, 2008 at 04:22:51PM +0200, T?r?k Edwin wrote:
> IMHO checking (fortifying) should be implemented for pthread_*
> functions, and here is my first attempt to do that for pthread_join.
> I've recently found a bug in a program due to its inapropriate use of
> pthread_join() [1], and neither gcc -fstack-protector [2], nor
> -D_FORTIFY_SOURCE=2 could detect the bug.
> The bug was that second param of pthread_join was pointing to an int,
> rather than a (void*); and since the sizes of those are different on
> x86-64 pthread_join overwrites the stack.

gcc 4.1 will warn:
warning: dereferencing type-punned pointer will break strict-aliasing rules
and if you just removed the bogus and unnecessary casts, any gcc would warn
too:
warning: passing argument 2 of ‘pthread_join’ from incompatible pointer type
Your patch is complete overkill.

	Jakub



More information about the Libc-alpha mailing list