From patchwork Tue Nov 13 11:39:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 997030 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-97203-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="NI4zxIVP"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42vQfB4n2vz9s9G for ; Tue, 13 Nov 2018 22:40:02 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; q=dns; s=default; b=McD5hbus+xpl3+8eKJAjLOhyMBX2g mDsnZdfWSMyxy3NDexrwzq2NDq6I/KLpi4qZW6VLLkTPt9L6vgpYGYFcHmCCjmcq wy6gPIq4SS9H0JtjsbTgIPg9QF+WtmEeJB2BBn6otHOpSiYMgC4pSuMRs4LKHYTg pVdT2kv3o6G4Dw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; s=default; bh=pMs8Pxeuqg6uV14dDs/6t0TWtlg=; b=NI4 zxIVPzzm0KBSzM5s+59rMiqEqLVrfYMnMsG6Iq0AaWk/IbJpq2+KMdGf2IOa/KBs cTcL8muRy1VQ3R8Nc/v/xv4nVmIhYMwpLALL7ecn2QACQQ9PaGDP5TIWvCfzYFAf sqsbWtJRN2trmz/LAedHjJWr/WW/RYBIv6OH/cLE= Received: (qmail 4207 invoked by alias); 13 Nov 2018 11:39:55 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 3773 invoked by uid 89); 13 Nov 2018 11:39:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH] malloc: Compile with -fno-strict-aliasing Date: Tue, 13 Nov 2018 12:39:45 +0100 Message-ID: <87y39xjjem.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Not sure what the performance impact will be. I think this will be quite nasty for the heap protector. But I don't see a way around this with the current malloc. Thanks, Florian malloc does this, among other things: To simplify use in double-linked lists, each bin header acts as a malloc_chunk. This avoids special-casing for headers. But to conserve space and improve locality, we allocate only the fd/bk pointers of bins, and then use repositioning tricks to treat these as the fields of a malloc_chunk*. This violates GCC's strict aliasing rules. 2018-11-13 Florian Weimer * malloc/Makefile (CFLAGS-malloc.c): Compile malloc.c if -fno-strict-aliasing due to aliasing violations. diff --git a/malloc/Makefile b/malloc/Makefile index 7d54bad866..a8cca0a4d6 100644 --- a/malloc/Makefile +++ b/malloc/Makefile @@ -171,6 +171,9 @@ include ../Rules CFLAGS-mcheck-init.c += $(PIC-ccflag) CFLAGS-obstack.c += $(uses-callbacks) +# malloc.c contains many aliasing violations. +CFLAGS-malloc.c += -fno-strict-aliasing + $(objpfx)libmcheck.a: $(objpfx)mcheck-init.o -rm -f $@ $(patsubst %/,cd % &&,$(objpfx)) \