This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
Re: PATCH/RFA free(NULL) bomb in printcmd.c
- To: Philippe De Muyter <phdm at macqel dot be>
- Subject: Re: PATCH/RFA free(NULL) bomb in printcmd.c
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Thu, 20 Apr 2000 19:51:34 +1000
- CC: gdb-patches at sourceware dot cygnus dot com
- Organization: Cygnus Solutions
- References: <200004110900.LAA01874@mail.macqel.be>
Philippe De Muyter wrote:
>
> Andrew Cagney wrote :
> > Um, I'm confused. wouldn't it be easier to just delete the two cleanup
> > calls (the first, perhaphs, replaced with make_cleanup (null_cleanup,
> > NULL))?
>
> Of course. But I did not know if the number of cleanups mattered, so I made
> my change as small as possible.
>
> [ 10 minutes reflexion and search ]
>
> The current situation and my and your `fixes' would have caused memory leaks,
> because the intention of the programmer there was actually to `free (name)'
> and `free (filename)', but `make_cleanup' is called before `name' and `filename'
> are allocated.
> I now think I have the correct fix. OK to commit ?
>
> Philippe De Muyter <phdm@macqel.be>
>
> * printcmd.c (print_address_symbolic): Call `make_cleanup' with
> `(free_current_contents, &x)', not `(free, x)'.
> * utils.c (free_current_contents): Do not `free (NULL)'.
FYI,
Something wierd is going on. For the d10v-elf target, FreeBSD 3.4
host. I see the regression:
x/d &oct
0x2007dc0: -1490098887
gdb in free(): warning: junk pointer, too high to make sense.
(gdb) FAIL: gdb.base/long_long.exp: x/d &oct
The warning appears all over the place. It suggests that something is
corrupting one of those pointers.
Andrew