From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 33720 invoked by alias); 18 Oct 2017 22:30:33 -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 33639 invoked by uid 89); 18 Oct 2017 22:30:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.4 required=5.0 tests=AWL,BAYES_00,DATE_IN_PAST_03_06,SPF_HELO_PASS,SPF_SOFTFAIL autolearn=no version=3.3.2 spammy= X-HELO: mail.baldwin.cx Received: from bigwig.baldwin.cx (HELO mail.baldwin.cx) (96.47.65.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 18 Oct 2017 22:30:27 +0000 Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id CB06610A8BA; Wed, 18 Oct 2017 18:30:25 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org Cc: Pedro Alves Subject: Re: [PATCH] xml_fetch_content_from_file: Read in whole file in one go (Re: [pushed] Fix double-free corruption) Date: Wed, 18 Oct 2017 22:30:00 -0000 Message-ID: <2811735.d9V1pPNBEL@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.1-STABLE; KDE/4.14.30; amd64; ; ) In-Reply-To: <199a50c3-4f55-c40e-7dcf-47db0ef27798@redhat.com> References: <1508240517-15322-1-git-send-email-palves@redhat.com> <199a50c3-4f55-c40e-7dcf-47db0ef27798@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-IsSubscribed: yes X-SW-Source: 2017-10/txt/msg00583.txt.bz2 On Tuesday, October 17, 2017 01:20:14 PM Pedro Alves wrote: > On 10/17/2017 12:41 PM, Pedro Alves wrote: > > Fixes a double-free regression introduced by commit b7b030adc405 > > ("Return unique_xmalloc_ptr from target_read_stralloc"): > > > > gdb.sum: > > Running src/gdb/testsuite/gdb.base/catch-syscall.exp ... > > ERROR: Process no longer exists > > > > > ... > > > > The problem is that if xrealloc decides it needs a new memory block, > > it frees the previous block/pointer, and then text.reset() frees it > > again. > > Looking a bit deeper, I can't seem to find a reason this code is > reading in chunks in the first place? Why not read it all in one > go? Like patch below. Seems sensible. It's unlikely that an XML file will be stored directly on a tape such that seek() is non-optimal. :) -- John Baldwin