From owner-freebsd-threads@FreeBSD.ORG Sat Mar 25 15:07:35 2006 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 97EC616A401 for ; Sat, 25 Mar 2006 15:07:35 +0000 (UTC) (envelope-from kabaev@gmail.com) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.227]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9E1B243D45 for ; Sat, 25 Mar 2006 15:07:34 +0000 (GMT) (envelope-from kabaev@gmail.com) Received: by wproxy.gmail.com with SMTP id 55so1214785wri for ; Sat, 25 Mar 2006 07:07:34 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer:mime-version:content-type:content-transfer-encoding; b=M0PwhLVjcXSgQ5nFkqre+L7SKjZ1uHloGHZQcrbAr7WbnQephrIRAqNnAtX6kvTXZenNiCI7OFkH8NLiQuKagR9KunwWK3NuOZTVtQY3aePeseYFQhnOUGK1iq/oMOF8rpWTR1vujByGlFiC69uE+mdYhGcXov6Xjw1dcH46cro= Received: by 10.54.154.16 with SMTP id b16mr1402553wre; Sat, 25 Mar 2006 07:07:33 -0800 (PST) Received: from kan.dnsalias.net ( [24.63.93.195]) by mx.gmail.com with ESMTP id 10sm1183377wrl.2006.03.25.07.07.32; Sat, 25 Mar 2006 07:07:32 -0800 (PST) Date: Sat, 25 Mar 2006 10:07:29 -0500 From: Alexander Kabaev To: Kostik Belousov Message-ID: <20060325100729.00713045@kan.dnsalias.net> In-Reply-To: <20060324084834.GE27116@deviant.kiev.zoral.com.ua> References: <44215FE9.2070602@highway.ne.jp> <20060322174312.GB27116@deviant.kiev.zoral.com.ua> <20060322190725.GC27116@deviant.kiev.zoral.com.ua> <4421BA34.8040908@highway.ne.jp> <20060323105440.GD27116@deviant.kiev.zoral.com.ua> <20060324084834.GE27116@deviant.kiev.zoral.com.ua> X-Mailer: Sylpheed-Claws 2.0.0 (GTK+ 2.8.15; i386-portbld-freebsd7.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org, freebsd-threads@freebsd.org Subject: Re: [patch] Re: dlopen() and dlclose() are not MT-safe? YES, esp. for libthr X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Mar 2006 15:07:35 -0000 On Fri, 24 Mar 2006 10:48:34 +0200 Kostik Belousov wrote: > I did understand the purpose of the thread mask code in > libexec/rtld/rtld_lock.c, or, more precisely, the condition where > this code works (for the context, see the mails with same subject on > freebsd-hackers). > > Look, that code assumes that blocking async signals would stop thread > scheduler from doing preemption of the current thread. This works > for libc_r, but fails in libpthread and libthr cases. libpthread > provides implementation of the locks for rtld. But libthr does not ! > > As result, rtld exhibit races when used with libthr. In other words, > libthr needs code to do proper locking. > > Do you agree ? Does somebody already planned to do this work ? > > Best regards, > Kostik Belousov The thread mask only makes sense when flags are per-thread. I meant to use it to detect PLT recursions from locking primitives exported to rtld by the threads library as those are not allowed and threads implementations are required to take special care to provide only self-contained locks. The 'default' lock implementation will not work with any library other than libc_r, and even that holds true only for some definition of "work". The dynamic loader never had a reliable locking and furthermore, there was no way to make it work better without threading library cooperation. This is why we came up with a set of callbacks rtld expects every threading library to provide. libpthread was the first where these callbacks were implemented. It comes as a surprise that libthr did not have them, because David Xu was the one who did most of the work on rtld locking callbacks in libpthread. The def_thread_set_flag function use is racy and should be fixed. -- Alexander Kabaev