public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [MI] Fix segfault for -remove-inferior
@ 2010-08-04 19:56 Marc Khouzam
  2010-08-05 14:47 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Marc Khouzam @ 2010-08-04 19:56 UTC (permalink / raw)
  To: 'gdb-patches@sourceware.org'

Hi,

I started to play around with MI multi-exec and got a segfault.
Below is the session showing the problem and the patch to fix it.
I think this should go into the 7.2 branch.

(I did not have time to run the test suite)

OK?

Marc


GNU gdb (GDB) 7.2.50.20100727-cvs
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) interpreter-exec mi "-remove-inferior i1"
Segmentation fault


2010-08-04  Marc Khouzam  <marc.khouzam@ericsson.com>

	* mi/mi-main.c (mi_cmd_remove_inferior): Properly access first argument.


### Eclipse Workspace Patch 1.0
#P src
Index: gdb/mi/mi-main.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
retrieving revision 1.178
diff -u -r1.178 mi-main.c
--- gdb/mi/mi-main.c    11 Jun 2010 15:36:07 -0000      1.178
+++ gdb/mi/mi-main.c    4 Aug 2010 19:40:19 -0000
@@ -1609,7 +1609,7 @@
   if (argc != 1)
     error ("-remove-inferior should be passed a single argument");
 
-  if (sscanf (argv[1], "i%d", &id) != 1)
+  if (sscanf (argv[0], "i%d", &id) != 1)
     error ("the thread group id is syntactically invalid");
 
   inf = find_inferior_id (id);
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [MI] Fix segfault for -remove-inferior
  2010-08-04 19:56 [MI] Fix segfault for -remove-inferior Marc Khouzam
@ 2010-08-05 14:47 ` Pedro Alves
  2010-08-05 16:07   ` Marc Khouzam
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2010-08-05 14:47 UTC (permalink / raw)
  To: gdb-patches; +Cc: Marc Khouzam

On Wednesday 04 August 2010 20:56:45, Marc Khouzam wrote:
> Hi,

Hi Marc,

> I started to play around with MI multi-exec and got a segfault.
> Below is the session showing the problem and the patch to fix it.

Thanks.

> I think this should go into the 7.2 branch.

Agreed.

> (I did not have time to run the test suite)

You can run the testsuite in parallel make mode nowadays.   E.g.,
on my laptop, "make check -j4" only takes around 5 minutes.
You can also run only the MI tests with:

 make check RUNTESTFLAGS="--directory=gdb.mi"

although, I don't think there's any test covering these MI
commands.  :-/

> OK?

Looks obviously correct to me.

-- 
Pedro Alves

> GNU gdb (GDB) 7.2.50.20100727-cvs
> Copyright (C) 2010 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "i686-pc-linux-gnu".
> For bug reporting instructions, please see:
> <http://www.gnu.org/software/gdb/bugs/>.
> (gdb) interpreter-exec mi "-remove-inferior i1"
> Segmentation fault
> 
> 
> 2010-08-04  Marc Khouzam  <marc.khouzam@ericsson.com>
> 
> 	* mi/mi-main.c (mi_cmd_remove_inferior): Properly access first argument.
> 
> 
> ### Eclipse Workspace Patch 1.0
> #P src
> Index: gdb/mi/mi-main.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
> retrieving revision 1.178
> diff -u -r1.178 mi-main.c
> --- gdb/mi/mi-main.c    11 Jun 2010 15:36:07 -0000      1.178
> +++ gdb/mi/mi-main.c    4 Aug 2010 19:40:19 -0000
> @@ -1609,7 +1609,7 @@
>    if (argc != 1)
>      error ("-remove-inferior should be passed a single argument");
>  
> -  if (sscanf (argv[1], "i%d", &id) != 1)
> +  if (sscanf (argv[0], "i%d", &id) != 1)
>      error ("the thread group id is syntactically invalid");
>  
>    inf = find_inferior_id (id);
>  

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [MI] Fix segfault for -remove-inferior
  2010-08-05 14:47 ` Pedro Alves
@ 2010-08-05 16:07   ` Marc Khouzam
  0 siblings, 0 replies; 3+ messages in thread
From: Marc Khouzam @ 2010-08-05 16:07 UTC (permalink / raw)
  To: 'Pedro Alves', 'gdb-patches@sourceware.org'

 

> You can run the testsuite in parallel make mode nowadays.   E.g.,
> on my laptop, "make check -j4" only takes around 5 minutes.

Cool!
I just ran it 4 or 5 times, since it was so fast :-)
Same results before and after the patch.

> > OK?
> 
> Looks obviously correct to me.

Checked-in to HEAD and 7_2.

Thanks

Marc

> 
> -- 
> Pedro Alves
> 
> > GNU gdb (GDB) 7.2.50.20100727-cvs
> > Copyright (C) 2010 Free Software Foundation, Inc.
> > License GPLv3+: GNU GPL version 3 or later 
> <http://gnu.org/licenses/gpl.html>
> > This is free software: you are free to change and redistribute it.
> > There is NO WARRANTY, to the extent permitted by law.  Type 
> "show copying"
> > and "show warranty" for details.
> > This GDB was configured as "i686-pc-linux-gnu".
> > For bug reporting instructions, please see:
> > <http://www.gnu.org/software/gdb/bugs/>.
> > (gdb) interpreter-exec mi "-remove-inferior i1"
> > Segmentation fault
> > 
> > 
> > 2010-08-04  Marc Khouzam  <marc.khouzam@ericsson.com>
> > 
> > 	* mi/mi-main.c (mi_cmd_remove_inferior): Properly 
> access first argument.
> > 
> > 
> > ### Eclipse Workspace Patch 1.0
> > #P src
> > Index: gdb/mi/mi-main.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
> > retrieving revision 1.178
> > diff -u -r1.178 mi-main.c
> > --- gdb/mi/mi-main.c    11 Jun 2010 15:36:07 -0000      1.178
> > +++ gdb/mi/mi-main.c    4 Aug 2010 19:40:19 -0000
> > @@ -1609,7 +1609,7 @@
> >    if (argc != 1)
> >      error ("-remove-inferior should be passed a single argument");
> >  
> > -  if (sscanf (argv[1], "i%d", &id) != 1)
> > +  if (sscanf (argv[0], "i%d", &id) != 1)
> >      error ("the thread group id is syntactically invalid");
> >  
> >    inf = find_inferior_id (id);
> >  
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-08-05 16:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-04 19:56 [MI] Fix segfault for -remove-inferior Marc Khouzam
2010-08-05 14:47 ` Pedro Alves
2010-08-05 16:07   ` Marc Khouzam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).