Hello,

I've checked with NetBSD-current from today (2020-02-02) and
pkgsrc-current (2020-02-02) and package firefox-72.0.2.

I'm not reproducing any crash due to pthread_equal(3) misuse. Everything
I tested, worked for me.

Please try PTHREAD_DIAGASSERT=ae and debug the culprit crash with a
core(5) file.

On 01.02.2020 22:20, Kamil Rytarowski wrote:
> 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" <ka...@netbsd.org> 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 // r...@tetera.org
>>> PGP fingerprint = 82A2 DC91 76E0 A10A 8ABB  FD1B F404 27FA C7D1 15F3
> 
> 


Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to