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 727B73858D28 for ; Tue, 14 Dec 2021 11:29:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 727B73858D28 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-421-knNt3rNpOse8pln_QIU5aw-1; Tue, 14 Dec 2021 06:29:04 -0500 X-MC-Unique: knNt3rNpOse8pln_QIU5aw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9D3E7801962; Tue, 14 Dec 2021 11:29:03 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.17.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CF7E76B8EA; Tue, 14 Dec 2021 11:29:02 +0000 (UTC) From: Florian Weimer To: Boris Ouretskey via Libc-help Subject: Re: Destruction order of function static members of different translation units References: Date: Tue, 14 Dec 2021 12:28:59 +0100 In-Reply-To: (Boris Ouretskey via Libc-help's message of "Thu, 9 Dec 2021 15:35:17 +0200") Message-ID: <87zgp3qvb8.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-help@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-help mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Dec 2021 11:29:14 -0000 * Boris Ouretskey via Libc-help: > I have seen some information on the mailing lists and forums but nothing > really focused. Not sure also if the question is for the libc community or > gcc . > > The situation we are dealing with is the "destruction fiasco". Because of > heavily templated code and many SO(DLL) translation units, which are using > common template headers, there are some static storage interdependencies > between functions' static members of different SO. For example:- Current glibc behavior is rather complex. You can try linking with -Wl,-z,now (or run with LD_BIND_NOW=1). This will eliminate relocation dependencies recorded late at run time and should make the order between construction and destruction more consistent. However, the objects are still dependency-sorted during process termination, and if the sort picks a different resolution, you might still get different destruction order. Would you be able to test a patch that always uses reserve order if possible? (There will still be exceptions because dlclose of unrelated objects can still result in different orders.) Thanks, Florian