Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Fix various default.exp failures
@ 2001-12-20  9:09 law
  2001-12-20  9:38 ` Fernando Nasser
  0 siblings, 1 reply; 2+ messages in thread
From: law @ 2001-12-20  9:09 UTC (permalink / raw)
  To: gdb-patches


default.exp has been intermittently failing on my HPs.  Not surprisingly the
problem is we're using uninitialized memory.

In my case, the problems show up (sometimes) when a "info set" command
is issued.  Typically, the problem shows up when we get to the 
"remotelogfile" entry in the set/show command list.

Basically we never initialize the "pre_show_hook" field in the cmd_list_element
structure for new commands we create via add_set_cmd.

Usually the value is zero and all is well, but sometimes the pre_show_hook
is nonzero (ie garbage).  Consider this code in do_setshow_command and what
happens if pre_show_hook is a nonzero garbage value:

      /* Possibly call the pre hook.  */
      if (c->pre_show_hook)
        (c->pre_show_hook) (c);

Yup, we make an indirect call to some unpredictable location which usually
results in a segfault.

The fix is trivial.  Initialize the pre_show_hook when we add the new command.

	* cli/cli-decode.c (add_cmd): Initialize pre_show_hook in
	the new command.

Index: cli/cli-decode.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/cli/cli-decode.c,v
retrieving revision 1.5
diff -c -3 -p -r1.5 cli-decode.c
*** cli-decode.c	2001/10/01 01:42:05	1.5
--- cli-decode.c	2001/12/20 17:06:22
*************** add_cmd (char *name, enum command_class 
*** 90,95 ****
--- 90,96 ----
    c->doc = doc;
    c->flags = 0;
    c->replacement = NULL;
+   c->pre_show_hook = NULL;
    c->hook_pre  = NULL;
    c->hook_post = NULL;
    c->hook_in = 0;










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

* Re: Fix various default.exp failures
  2001-12-20  9:09 Fix various default.exp failures law
@ 2001-12-20  9:38 ` Fernando Nasser
  0 siblings, 0 replies; 2+ messages in thread
From: Fernando Nasser @ 2001-12-20  9:38 UTC (permalink / raw)
  To: law; +Cc: gdb-patches

You can check this in as an obvious fix.

Fernando

law@redhat.com wrote:
> 
> default.exp has been intermittently failing on my HPs.  Not surprisingly the
> problem is we're using uninitialized memory.
> 
> In my case, the problems show up (sometimes) when a "info set" command
> is issued.  Typically, the problem shows up when we get to the
> "remotelogfile" entry in the set/show command list.
> 
> Basically we never initialize the "pre_show_hook" field in the cmd_list_element
> structure for new commands we create via add_set_cmd.
> 
> Usually the value is zero and all is well, but sometimes the pre_show_hook
> is nonzero (ie garbage).  Consider this code in do_setshow_command and what
> happens if pre_show_hook is a nonzero garbage value:
> 
>       /* Possibly call the pre hook.  */
>       if (c->pre_show_hook)
>         (c->pre_show_hook) (c);
> 
> Yup, we make an indirect call to some unpredictable location which usually
> results in a segfault.
> 
> The fix is trivial.  Initialize the pre_show_hook when we add the new command.
> 
>         * cli/cli-decode.c (add_cmd): Initialize pre_show_hook in
>         the new command.
> 
> Index: cli/cli-decode.c
> ===================================================================
> RCS file: /cvs/cvsfiles/devo/gdb/cli/cli-decode.c,v
> retrieving revision 1.5
> diff -c -3 -p -r1.5 cli-decode.c
> *** cli-decode.c        2001/10/01 01:42:05     1.5
> --- cli-decode.c        2001/12/20 17:06:22
> *************** add_cmd (char *name, enum command_class
> *** 90,95 ****
> --- 90,96 ----
>     c->doc = doc;
>     c->flags = 0;
>     c->replacement = NULL;
> +   c->pre_show_hook = NULL;
>     c->hook_pre  = NULL;
>     c->hook_post = NULL;
>     c->hook_in = 0;

-- 
Fernando Nasser
Red Hat Canada Ltd.                     E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9


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

end of thread, other threads:[~2001-12-20 17:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-20  9:09 Fix various default.exp failures law
2001-12-20  9:38 ` Fernando Nasser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox