Message ID | 410dda80c8530a193308630ff74a456fadd4bc9e.1444820235.git.henrik.wallin@windriver.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 73930 invoked by alias); 14 Oct 2015 11:14:40 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 69777 invoked by uid 89); 14 Oct 2015 11:14:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=1.0 required=5.0 tests=BAYES_20, KAM_LAZY_DOMAIN_SECURITY, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mail.windriver.com Received: from mail.windriver.com (HELO mail.windriver.com) (147.11.1.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 14 Oct 2015 11:14:36 +0000 Received: from arn-build2.wrs.com (arn-build2.wrs.com [128.224.95.15]) by mail.windriver.com (8.15.2/8.15.1) with ESMTP id t9EBEY0u010702 for <gdb-patches@sourceware.org>; Wed, 14 Oct 2015 04:14:34 -0700 (PDT) Received: by arn-build2.wrs.com (Postfix, from userid 18580) id D73782207BD; Wed, 14 Oct 2015 13:14:33 +0200 (CEST) From: henrik.wallin@windriver.com To: gdb-patches@sourceware.org Subject: [RFC][PATCH 04/15] Fix crash in tstatus after detach Date: Wed, 14 Oct 2015 13:14:22 +0200 Message-Id: <410dda80c8530a193308630ff74a456fadd4bc9e.1444820235.git.henrik.wallin@windriver.com> In-Reply-To: <cover.1444820235.git.henrik.wallin@windriver.com> References: <cover.1444820235.git.henrik.wallin@windriver.com> In-Reply-To: <cover.1444820235.git.henrik.wallin@windriver.com> References: <cover.1444820235.git.henrik.wallin@windriver.com> |
Commit Message
henrik.wallin@windriver.com
Oct. 14, 2015, 11:14 a.m. UTC
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. 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(+)
Comments
Hi Henrik, henrik.wallin@windriver.com wrote: > 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; > } > Please don't introduce "#ifdef GDBSERVER" conditionals into common code, I spent some time removing them last year. I know I didn't get them all, but the remaining two are on my hit list :) Thanks, Gary
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
2015-10-15 19:22 GMT+02:00 Pedro Alves <palves@redhat.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? I will do, after I manage to actually reproduce this one... The patch was done on 7.6 and then rebased. I will check some more but it looks like this might've been fixed by some other changes between 7.6 and master. > >> >> 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. I will check that. thanks, / Henrik
2015-10-14 13:48 GMT+02:00 Gary Benson <gbenson@redhat.com>: > Hi Henrik, > > henrik.wallin@windriver.com wrote: >> 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; >> } >> > > Please don't introduce "#ifdef GDBSERVER" conditionals into common > code, I spent some time removing them last year. I know I didn't > get them all, but the remaining two are on my hit list :) Ok :) I will check that. thanks, / Henrik
Wallin, Henrik wrote: > 2015-10-14 13:48 GMT+02:00 Gary Benson <gbenson@redhat.com>: > > henrik.wallin@windriver.com wrote: > > > 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; > > > } > > > > > > > Please don't introduce "#ifdef GDBSERVER" conditionals into common > > code, I spent some time removing them last year. I know I didn't > > get them all, but the remaining two are on my hit list :) > > Ok :) > I will check that. Thanks Henrik. Cheers, Gary
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; }