[PATCH] D39619: Correct atexit(3) support in TSan/NetBSD

Kamil Rytarowski via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 8 16:09:42 PST 2017


On 08.11.2017 17:42, Dmitry Vyukov wrote:
> On Wed, Nov 8, 2017 at 5:29 PM, Kamil Rytarowski via Phabricator
> <reviews at reviews.llvm.org> wrote:
>> krytarowski added a comment.
>>
>> Thanks for review, I will commit it tonight!
>>
>> The remaining problems with TSan/NetBSD:
>>
>> - Mutex tracking is broken, they seem to be not registered (in ScopedReport::AddMemoryAccess we always get mset->Size() equal to 0)
> 
> 
> This is strange.
> If pthread_mutex/spinlock, etc interceptors work, then it should be
> enough for mset's to work. The interceptors call
> MutexPre/PostLock/Unlock and from that point everything is
> platform-independent.
> 

Could you please set a breakpoint in the place when we increase mset (so
Size() is > 0) and share backtrace (with __FILE__:__LINE__)? This will
help to narrow down the problem for me.

I have an access to Clang 3.9/Linux that predates Pre/Post Lock split
and so far I don't see anything wrong on my side.

> 
> 
>> - Thread Deatch and Thread Joined can race and assert that they go in the wrong order (we destroy a thread before marking it Finished)
> 
> That's probably because we now call ThreadFinish too late (from
> _lwp_exit), and at that point pthread_join for this thread has already
> returned.
> For pthread_join maybe we could wait for _lwp_exit completion before
> calling ThreadJoin.
> Not yet sure what to do for detach.
> 

https://nxr.netbsd.org/xref/src/lib/libpthread/pthread.c#665

    679 		self->pt_state = PT_STATE_ZOMBIE;
    680 		pthread_cond_broadcast(&self->pt_joiners);
    681 		pthread_mutex_unlock(&self->pt_lock);
    682 		/* Note: name will be freed by the joiner. */
    683 		_lwp_exit();

So, we cv_broadcast joiners and call _lwp_exit().
Another thread is calling cv_wait() and collecting it.

There is also another variation with calling pthread_detach() so a
thread is usually not waiting for being joined.

> 
>>
>> Less important ones:
>>
>> - setjmp/longjmp unimplemented for NetBSD
>> - StartBackgroundThread() is not executed (need to be deferred)
>>
>>
>> Repository:
>>   rL LLVM
>>
>> https://reviews.llvm.org/D39619
>>
>>
>>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171109/8abbc889/attachment.sig>


More information about the llvm-commits mailing list