This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC][PATCH 04/15] Fix crash in tstatus after detach
- From: Pedro Alves <palves at redhat dot com>
- To: henrik dot wallin at windriver dot com, gdb-patches at sourceware dot org
- Date: Thu, 15 Oct 2015 18:22:48 +0100
- Subject: Re: [RFC][PATCH 04/15] Fix crash in tstatus after detach
- Authentication-results: sourceware.org; auth=none
- References: <cover dot 1444820235 dot git dot henrik dot wallin at windriver dot com> <410dda80c8530a193308630ff74a456fadd4bc9e dot 1444820235 dot git dot henrik dot wallin at windriver dot com>
On 10/14/2015 12:14 PM, henrik.wallin@windriver.com wrote:
> From: Par Olsson <par.olsson@windriver.com>
>
> When calling tstatus after detaching the process,
> gdbserver tries to access inferior memory which
> results in a crash.
> This changes the behavior of the agent_loaded_p()
> to return false if no inferior is loaded.
Sounds like it should be easy to cook up a testcase.
Could you do that?
>
> gdb/ChangeLog:
>
> * agent.c (agent_loaded_p): Add check that inferior is present.
>
> Signed-off-by: Par Olsson <par.olsson@windriver.com>
> Signed-off-by: Henrik Wallin <henrik.wallin@windriver.com>
> ---
> gdb/common/agent.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/gdb/common/agent.c b/gdb/common/agent.c
> index 5c307290589d..c9b6c41bc4ff 100644
> --- a/gdb/common/agent.c
> +++ b/gdb/common/agent.c
> @@ -73,9 +73,16 @@ static struct ipa_sym_addresses ipa_sym_addrs;
>
> static int all_agent_symbols_looked_up = 0;
>
> +#ifdef GDBSERVER
> +#include <inferiors.h>
> +#endif
> int
> agent_loaded_p (void)
> {
> +#ifdef GDBSERVER
> + if (current_thread == NULL)
> + return 0;
> +#endif
> return all_agent_symbols_looked_up;
> }
>
Should probably be moved up to the caller.
Thanks,
Pedro Alves