Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/lib/libpthread



Good idea. It could be checked quicker... however I presume that
t1->pt_magic + t1->pt_magic already crash on invalid t1/t2 pointers as
the argument with condition is evaluated.

Ryo, you might check:
$ export PTHREAD_DIAGASSERT=ae
$ firefox

It should create a coredump for investigation.

According to POSIX
(https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_equal.html)
passing invalid parameters is UB.

GLIBC, Illumos and all other BSDs (+ older NetBSD) have no sanity check
in pthread_equal(3). Apparently we are the first ones to notice the bug.

On 01.02.2020 21:18, Andrew Doran wrote:
> Hmm.  Was there not originally an environment variable to control this
> behaviour, since many applications are buggy?
> 
> Andrew
> 
> On Sun, Feb 02, 2020 at 01:01:49AM +0900, Ryo ONODERA wrote:
>> Hi,
>>
>> pthread__error()s in pthread_equal() cause segfault
>> during start of pkgsrc/www/firefox-72.0.2.
>>
>> Without pthread__error()s, www/firefox works fine
>> like as follows.
>> However I have no idea why I get segfaults.
>>
>> Could you take a look at this problem?
>>
>> Index: lib/libpthread/pthread.c
>> ===================================================================
>> RCS file: /cvsroot/src/lib/libpthread/pthread.c,v
>> retrieving revision 1.162
>> diff -u -r1.162 pthread.c
>> --- lib/libpthread/pthread.c	29 Jan 2020 17:11:57 -0000	1.162
>> +++ lib/libpthread/pthread.c	1 Feb 2020 15:58:03 -0000
>> @@ -770,11 +770,13 @@
>>  	if (__predict_false(__uselibcstub))
>>  		return __libc_thr_equal_stub(t1, t2);
>>  
>> +#if 0
>>  	pthread__error(EINVAL, "Invalid thread",
>>  	    t1->pt_magic == PT_MAGIC);
>>  
>>  	pthread__error(EINVAL, "Invalid thread",
>>  	    t2->pt_magic == PT_MAGIC);
>> +#endif
>>  
>>  	/* Nothing special here. */
>>  	return (t1 == t2);
>> @@ -1108,7 +1110,7 @@
>>  {
>>  	char buf[1024];
>>  	size_t len;
>> -	
>> +
>>  	if (pthread__diagassert == 0)
>>  		return;
>>  
>>
>>
>> "Kamil Rytarowski" <kamil%netbsd.org@localhost> writes:
>>
>>> Module Name:	src
>>> Committed By:	kamil
>>> Date:		Wed Jan 29 16:03:44 UTC 2020
>>>
>>> Modified Files:
>>> 	src/lib/libpthread: pthread.c pthread_getcpuclockid.c
>>>
>>> Log Message:
>>> Chack thread->pt_magic with PT_MAGIC promptly
>>>
>>> Rearrange some checks to avoid verifying pthread_t after using it.
>>>
>>>
>>> To generate a diff of this commit:
>>> cvs rdiff -u -r1.160 -r1.161 src/lib/libpthread/pthread.c
>>> cvs rdiff -u -r1.2 -r1.3 src/lib/libpthread/pthread_getcpuclockid.c
>>>
>>> Please note that diffs are not public domain; they are subject to the
>>> copyright notices on the relevant files.
>>>
>>
>> -- 
>> Ryo ONODERA // ryo%tetera.org@localhost
>> PGP fingerprint = 82A2 DC91 76E0 A10A 8ABB  FD1B F404 27FA C7D1 15F3


Attachment: signature.asc
Description: OpenPGP digital signature



Home | Main Index | Thread Index | Old Index