This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Fix access to uninitialized variable in fill_in_stop_func
- From: Kevin Buettner <kevinb at redhat dot com>
- To: gdb-patches at sourceware dot org
- Cc: Tom Tromey <tom at tromey dot com>, Pedro Franco de Carvalho <pedromfc at linux dot ibm dot com>
- Date: Thu, 8 Aug 2019 10:42:00 -0700
- Subject: Re: [PATCH] Fix access to uninitialized variable in fill_in_stop_func
- References: <20190808135443.10894-1-pedromfc@linux.ibm.com> <87lfw360lt.fsf@tromey.com>
On Thu, 08 Aug 2019 11:14:22 -0600
Tom Tromey <tom@tromey.com> wrote:
> >>>>> "Pedro" == Pedro Franco de Carvalho <pedromfc@linux.ibm.com> writes:
>
> Pedro> This patch changes fill_in_stop_func to check the return value of
> Pedro> find_pc_partial_function before accessing the block pointer that is only
> Pedro> written by find_pc_partial_function if it returns a success status.
>
> Pedro> gdb/ChangeLog:
> Pedro> YYYY-MM-DD Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
>
> Pedro> * infrun.c (fill_in_stop_func): Use return value of
> Pedro> find_pc_partial_function, remove comment.
>
> The comment for find_pc_partial_function says:
>
> nullptr is used as a return value for *BLOCK if no block is found.
>
> ... which implies to me that the function was intended to set *BLOCK
> unconditionally. Perhaps Kevin could say, as I think he added the block
> parameter.
Yes, that was the intent, but unfortunately, that's not what's happening.
find_pc_partial_function contains the following return path...
if (msymbol.minsym == NULL)
{
/* No available symbol. */
if (name != NULL)
*name = 0;
if (address != NULL)
*address = 0;
if (endaddr != NULL)
*endaddr = 0;
return 0;
}
...which does not set *BLOCK.
I think I'd prefer to see...
if (block != nullptr)
*block = nullptr;
...added to find_pc_partial_function instead.
Kevin