This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: vfprintf_maybe_filtered should check vasprintf return value


Eirik Fuller wrote:
> 
> In gdb-5.0 (and, as far as I can tell, later versions of gdb), the
> return value of vasprintf is not checked by vfprintf_maybe_filtered.
> I've found at least one crash which can result from this; if I try
> 
>         printf "%ls\n", version
> 
> on gdb's own symbol table, I get a segfault because linebuffer is
> unchanged by vasprintf, on a Debian GNU/Linux system with the
> vasprintf provided by glibc-2.1.3.

What is causing the call to fail?  A dud malloc() normally leads to a
NULL value.
If vasprintf() in glibc-2.1.3 is broken then, perhaphs we should use the
libiberty version.

The gdb/TODO file suggests adding the functions xasprintf() /
xvasprintf() to address this problem.

> With the enclosed patch, I get an error message instead of a crash.
> I make no claims about the optimality of the error message, but I
> believe the patch is fundamentally sound.  Please let me know if
> the crash isn't easily repeatable (it is for me), or if any further
> information is required.

It should probably call internal_error() or just use xvasprintf().

sorry for all the questions,
	Andrew

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]