From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3849 invoked by alias); 20 Dec 2001 17:09:06 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 3157 invoked from network); 20 Dec 2001 17:07:46 -0000 Received: from unknown (HELO cygnus.com) (205.180.230.5) by sources.redhat.com with SMTP; 20 Dec 2001 17:07:46 -0000 Received: from porcupine.cygnus.com (cse.cygnus.com [205.180.230.236]) by runyon.cygnus.com (8.8.7-cygnus/8.8.7) with ESMTP id JAA27294 for ; Thu, 20 Dec 2001 09:07:43 -0800 (PST) Received: from porcupine.cygnus.com (law@localhost) by porcupine.cygnus.com (8.11.6/8.11.6) with ESMTP id fBKH7BD25874 for ; Thu, 20 Dec 2001 10:07:12 -0700 X-Mailer: exmh version 2.4 06/23/2000 with nmh-1.0.4 To: gdb-patches@sources.redhat.com Reply-to: law@redhat.com From: law@redhat.com Subject: Fix various default.exp failures Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 20 Dec 2001 09:09:00 -0000 Message-ID: <25873.1008868031@porcupine.cygnus.com> X-SW-Source: 2001-12/txt/msg00520.txt.bz2 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;