From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 91768 invoked by alias); 17 May 2017 11:35:58 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 91751 invoked by uid 89); 17 May 2017 11:35:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE autolearn=no version=3.3.2 spammy=Discussion, neat, month, our X-HELO: mail-wr0-f176.google.com Received: from mail-wr0-f176.google.com (HELO mail-wr0-f176.google.com) (209.85.128.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 17 May 2017 11:35:56 +0000 Received: by mail-wr0-f176.google.com with SMTP id l9so7073199wre.1 for ; Wed, 17 May 2017 04:35:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=ORlRtwCrVeW/7CVUiAPgTm1aW6FipBYxIssg6BRvWZ0=; b=mMWf0acFCPmNF1al+LHC9ezpQIf9L5buQqu1E5a7ilhPmOQ5NbJGhN6f0Y3PLvTkje /suGYPwvVKuzROObYka5vfT919v/+Dy0L2GdXwfWCyUl6aETytltrXv6BBxcMx/Op7m5 QMG01qzUAFvyAZDkAf2/douUvfDD+3RmXrb68vGdL00PScWH+SDwJDi9S41ONLHEskha Lf0Tmr1EJzyM/cm7+CWiRJ9rHcD+NP3JyTYy81oWm0eG3kPxN+50v08Ddvh4LK0SCwdL 9oyKxQz4XlIC6u+rbXQUxJqzdYoBH3NJR+s5Owt3L1c5yN8rP31EVD6u8lgdNlbsS3RU oTKA== X-Gm-Message-State: AODbwcDpXEcLGynI1vgX3PBLYL4esS+yrnK3xhQlmlAG7TLNXNK48CwD uPbLB9idvrCeL9xrAf143A== X-Received: by 10.223.147.228 with SMTP id 91mr1803370wrp.47.1495020957068; Wed, 17 May 2017 04:35:57 -0700 (PDT) Received: from [192.168.0.101] ([37.189.166.198]) by smtp.gmail.com with ESMTPSA id g90sm1797877wrd.11.2017.05.17.04.35.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 May 2017 04:35:56 -0700 (PDT) Subject: Re: [PATCH 1/5] Poison non-POD memset & non-trivially-copyable memcpy/memmove To: Simon Marchi References: <1492050475-9238-1-git-send-email-palves@redhat.com> <1492050475-9238-2-git-send-email-palves@redhat.com> <9ee5551a7999a72a0040f15e6e5410a1@polymtl.ca> <9c15c7f2d50cdb53f39719dba3eb589e@polymtl.ca> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: <0e73c6f0-4719-79e6-26bd-e31587b531af@redhat.com> Date: Wed, 17 May 2017 11:35:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <9c15c7f2d50cdb53f39719dba3eb589e@polymtl.ca> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-05/txt/msg00379.txt.bz2 On 04/30/2017 02:51 AM, Simon Marchi wrote: > I think it would be a good guideline to use new/delete for types that > have some C++-related stuff in them, even if it's not technically > necessary. > > Note that this won't be bulletproof also because at many places xfree is > used on a void pointer, so we don't know what we're really free'ing. In > some other cases, objects are freed using a pointer to their "C base > class". Yeah. Still, better than nothing. BTW, GCC ran into similar issues almost at the same time we started discussing this, and I've been discussing with the GCC folks about a new GCC warning that flags invalid memcpy/memset misuses. Martin Sebor has been working on a patch and it's getting close to be merged, AFAICT. See: https://gcc.gnu.org/ml/gcc-patches/2017-04/msg01527.html First version of the GCC patch here: https://gcc.gnu.org/ml/gcc-patches/2017-04/msg01571.html Discussion crossed month boundary here: https://gcc.gnu.org/ml/gcc-patches/2017-05/msg00925.html Latest patch is here: https://gcc.gnu.org/ml/gcc-patches/2017-05/msg00976.html I won't be a full replacement since we'll still want our poisoning for other functions (xmalloc, xfree, etc.). And then there's current/older gccs. But still, pretty neat, IMO. Thanks, Pedro Alves