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 46AE93858C66 for ; Tue, 4 Apr 2023 10:26:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 46AE93858C66 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=1680603996; 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=slLfUCFld8gwCZeqyoWc1Yf5P8oMbB38xwUZEQn+0iE=; b=TDRxDq0zJzyJDi5/EBN38CBGtlczhcNG7xf6lulSoMX78iXU1SLthH26amYd55GvLH8NaW HBBvgxJRwvk7I6R553V16VchtspPj+GgmlB5owa5AeGxq6vdHPgQirHLtg0pmP7oyFTLal VjdbEnzuf46/6Ax7Z+V6z0Hxlv4AZpk= 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-648-pRrvkc4vNsGF5oP0FQyutg-1; Tue, 04 Apr 2023 06:26:35 -0400 X-MC-Unique: pRrvkc4vNsGF5oP0FQyutg-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 925CD185A78F for ; Tue, 4 Apr 2023 10:26:35 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.130]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AEA7140C6EC4; Tue, 4 Apr 2023 10:26:34 +0000 (UTC) From: Florian Weimer To: DJ Delorie via Libc-alpha Cc: DJ Delorie Subject: Re: [patch v1] malloc: set NON_MAIN_ARENA flag for reclaimed memalign chunk (BZ #30101) References: Date: Tue, 04 Apr 2023 12:26:32 +0200 In-Reply-To: (DJ Delorie via Libc-alpha's message of "Mon, 03 Apr 2023 18:12:52 -0400") Message-ID: <87pm8kgcyv.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=-10.5 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_H2,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 via Libc-alpha: > From 61bd502ecac4d63f04c74bfc491ca675660d26b7 Mon Sep 17 00:00:00 2001 > From: DJ Delorie > Date: Mon, 3 Apr 2023 17:33:03 -0400 > Subject: malloc: set NON_MAIN_ARENA flag for reclaimed memalign chunk (BZ #30101) > > Based on these comments in malloc.c: > > size field is or'ed with NON_MAIN_ARENA if the chunk was obtained > from a non-main arena. This is only set immediately before handing > the chunk to the user, if necessary. > > The NON_MAIN_ARENA flag is never set for unsorted chunks, so it > does not have to be taken into account in size comparisons. > > When we pull a chunk off the unsorted list (or any list) we need to > make sure that flag is set properly before returning the chunk. > > diff --git a/malloc/malloc.c b/malloc/malloc.c > index 0315ac5d16..66e7ca57dd 100644 > --- a/malloc/malloc.c > +++ b/malloc/malloc.c > @@ -5147,6 +5147,8 @@ _int_memalign (mstate av, size_t alignment, size_t bytes) > p = victim; > m = chunk2mem (p); > set_inuse (p); > + if (av != &main_arena) > + set_non_main_arena (p); > } > else > { The change looks reasonable. Can we add a test for this? Maybe run the existing memalign tests on a second thread as well? Thanks, Florian