[PATCH] xml_fetch_content_from_file: Read in whole file in one go (Re: [pushed] Fix double-free corruption)

John Baldwin jhb@freebsd.org
Wed Oct 18 22:30:00 GMT 2017


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



More information about the Gdb-patches mailing list