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.133.124]) by sourceware.org (Postfix) with ESMTPS id 611233858D1E for ; Fri, 1 Sep 2023 21:29:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 611233858D1E 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=1693603751; 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=YB9OaFzkg5rBOW1jjA2PxyqbZ+h0UCotdZs2RaGFILg=; b=LuSAjoorM4QF9MbKTDKrZknt7xHzXRTuf5/BpB0KjU+pFoV/kLLhHnxm8awJ4MlVnjw5gp 3PQAxUFC4fdycxjYrQqbh458anlRgYUUCPD1v1jpI2GmUSOnDyYHZ+UJG6VKZMLDxqOKQ/ MXhBLm4uA1Lu+rmBA/xHxHyDoie4vLw= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-584-R466uzUePMGs0E4RVaIlhw-1; Fri, 01 Sep 2023 17:29:09 -0400 X-MC-Unique: R466uzUePMGs0E4RVaIlhw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 753D61C18C7F for ; Fri, 1 Sep 2023 21:29:09 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.11]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 01302400E13E; Fri, 1 Sep 2023 21:29:08 +0000 (UTC) From: Florian Weimer To: DJ Delorie Cc: libc-alpha@sourceware.org Subject: Re: [PATCH v3 2/2] elf: Always call destructors in reverse constructor order (bug 30785) References: Date: Fri, 01 Sep 2023 23:29:07 +0200 In-Reply-To: (DJ Delorie's message of "Fri, 01 Sep 2023 13:59:57 -0400") Message-ID: <878r9poa58.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.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP 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: * DJ Delorie: >> /* Is there a destructor function? */ >> if (l->l_info[DT_FINI_ARRAY] != NULL >> || (ELF_INITFINI && l->l_info[DT_FINI] != NULL)) >> { >> /* When debugging print a message first. */ >> if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0)) >> _dl_debug_printf ("\ncalling fini: %s [%lu]\n\n", >> DSO_FILENAME (l->l_name), l->l_ns); >> >> /* First see whether an array is given. */ >> if (l->l_info[DT_FINI_ARRAY] != NULL) >> { >> ElfW(Addr) *array = >> (ElfW(Addr) *) (l->l_addr >> + l->l_info[DT_FINI_ARRAY]->d_un.d_ptr); >> unsigned int i = (l->l_info[DT_FINI_ARRAYSZ]->d_un.d_val >> / sizeof (ElfW(Addr))); >> while (i-- > 0) >> ((fini_t) array[i]) (); >> } >> >> /* Next try the old-style destructor. */ >> if (ELF_INITFINI && l->l_info[DT_FINI] != NULL) >> DL_CALL_DT_FINI (l, l->l_addr + l->l_info[DT_FINI]->d_un.d_ptr); >> } > > Similar to _dl_call_fini(), but... doesn't set map->l_init_called ? Ok, > but seems repetitive. Huh. I think this might be a merge/rebase issue. Good catch. The original code did not have this consolidation, but it has /* Make sure nothing happens if we are called twice. */ l->l_init_called = 0; It is redundant because of the earlier bump of the reference counters, which prevents nested dlclose calls from doing anything because the reference counters will not reach zero. But incorporating the _dl_call_fini consolidation is a good idea. I'll do that next week, retest & repost. Thanks, Florian