From patchwork Fri Nov 13 16:14:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 41046 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D8C7C393C85B; Fri, 13 Nov 2020 16:14:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D8C7C393C85B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605284062; bh=cO09LLVhS55vu+HV4yVzFqcK1Q0szmKchQDC7WNK10I=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=SrioTzX5tL+t5pJ3UG8Hh2xdQIwajlfxTI0p47SyyuMH7FB35a1C7qrapP48YM7QL 6/xgHUgBFBLHkV1hROR2mDANsAi8aUI0c+0CAxucixkTD1sLw5tKI8CGu+4ySme2Oy 1E0T6mqIeP/Q6sQqnmcSqEHxPGdaecw2bAJsrgIc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id E876B393C85A for ; Fri, 13 Nov 2020 16:14:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E876B393C85A Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-8-hVHkuJB6OMqIh-OHN36fbQ-1; Fri, 13 Nov 2020 11:14:18 -0500 X-MC-Unique: hVHkuJB6OMqIh-OHN36fbQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B540E1009E33 for ; Fri, 13 Nov 2020 16:14:17 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-113-222.ams2.redhat.com [10.36.113.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3196F62A16 for ; Fri, 13 Nov 2020 16:14:17 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 2/2] malloc: Use __libc_type to detect an inner libc In-Reply-To: <7e89ec4dee33dd4eef6986dd0e790a9500c430b6.1605283657.git.fweimer@redhat.com> References: <7e89ec4dee33dd4eef6986dd0e790a9500c430b6.1605283657.git.fweimer@redhat.com> Message-Id: Date: Fri, 13 Nov 2020 17:14:15 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The inner libc must not use sbrk. _dl_addr occasionally shows up in profiles, but had to be used before because __libc_multiple_libs was unreliable. --- malloc/arena.c | 7 +------ malloc/malloc.c | 2 ++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/malloc/arena.c b/malloc/arena.c index 202daf15b0..865eaa1a84 100644 --- a/malloc/arena.c +++ b/malloc/arena.c @@ -296,12 +296,7 @@ ptmalloc_init (void) #ifdef SHARED /* In case this libc copy is in a non-default namespace, never use brk. Likewise if dlopened from statically linked program. */ - Dl_info di; - struct link_map *l; - - if (_dl_open_hook != NULL - || (_dl_addr (ptmalloc_init, &di, &l, NULL) != 0 - && l->l_ns != LM_ID_BASE)) + if (__libc_type == libc_type_secondary) __morecore = __failing_morecore; #endif diff --git a/malloc/malloc.c b/malloc/malloc.c index 5b87bdb081..0834e4181a 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -247,6 +247,8 @@ /* For SINGLE_THREAD_P. */ #include +#include + /* Debugging: