From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 6F3723858D37 for ; Thu, 25 May 2023 19:06:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6F3723858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685041581; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=uCd/sDUjFcwJQIBvfNUI1bqZBC9FTWj8pKZ6kfe/rzk=; b=Cyys5yguuDrz9Skc4pFoKovlhNpd41aqLDOKoFlxHMMNG4J3GlCj/DtGa6ms5wH6ojOIpW ca6hsxlwV7rHYK9UFY6s6riJ3Wju2Y7FJspAJyFzOpzExsn57ulKlIJNAoeVc6pi2jsyKa LZYpDvBonQV8++tmTYF60UOT4zyXWGw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-571-YnswL5S8N5-_uplxY9ct6g-1; Thu, 25 May 2023 15:06:18 -0400 X-MC-Unique: YnswL5S8N5-_uplxY9ct6g-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7635E85A5BD for ; Thu, 25 May 2023 19:06:18 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.8]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B6644492B00; Thu, 25 May 2023 19:06:17 +0000 (UTC) From: Florian Weimer To: Carlos O'Donell Cc: libc-alpha@sourceware.org Subject: Re: [PATCH v2] elf: Make more functions available for binding during dlclose (bug 30425) References: <87mt1w4n54.fsf@oldenburg3.str.redhat.com> Date: Thu, 25 May 2023 21:06:16 +0200 In-Reply-To: (Carlos O'Donell's message of "Thu, 25 May 2023 14:57:28 -0400") Message-ID: <87wn0wi63b.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: * Carlos O'Donell: > On 5/22/23 07:32, Florian Weimer via Libc-alpha wrote: >> Previously, after destructors for a DSO have been invoked, ld.so refused >> to bind against that DSO in all cases. Relax this restriction somewhat >> if the referencing object is itself a DSO that is being unloaded. This >> assumes that the symbol reference is not going to be stored anywhere. > > The truth here is that the example has a circular reference due to the > interposition which makes it have an undefined load and unload > order. You wrote a very specific test that *avoids* needing anything > from mod1 during mod2's initialization. It's possible to create this situation with C++ code due to vague linkage. No explicit interposition is needed. I didn't want to incorporate the C++ test case because it's brittle: it depends on which functions the compiler emits. (It has some leeway because of vague linkage.) > Having said all that we should *choose* an unload order that is the > opposite of the load order and make it consistent, and if we could > load it we should not fail to unload it because of a limitation of the > dynamic loader. We might still fail due to some logical dependency in > user code though. > > The DT_NEEDED in mod1 ensures we load: mod2 then mod1. The closing of > mod1 should unload: mod1 then mod2 (opposite order). > > This consistent order should make it easier for users to debug other > problems in their library designs. Yeah, sure? But that's how it's always been? >> The situation in the test case can arise fairly easily with C++ and >> objects that are built with different optimization levels and therefore >> define different functions with vague linkage. > > Please post a v3. With the comment updates? Or some other changes? Thanks, Florian