From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29660 invoked by alias); 6 Aug 2010 14:23:13 -0000 Received: (qmail 29651 invoked by uid 22791); 6 Aug 2010 14:23:12 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 06 Aug 2010 14:23:04 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o76EN2CO022615 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 6 Aug 2010 10:23:02 -0400 Received: from host1.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o76EMxm9012552 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 6 Aug 2010 10:23:01 -0400 Received: from host1.dyn.jankratochvil.net (localhost [127.0.0.1]) by host1.dyn.jankratochvil.net (8.14.4/8.14.4) with ESMTP id o76EMxu8020095 for ; Fri, 6 Aug 2010 16:22:59 +0200 Received: (from jkratoch@localhost) by host1.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id o76EMxVX020090 for gdb-patches@sourceware.org; Fri, 6 Aug 2010 16:22:59 +0200 Date: Fri, 06 Aug 2010 14:23:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch] [mi] Fix crash on stale frame_info * - PR 11788 Message-ID: <20100806142259.GA19570@host1.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-08/txt/msg00065.txt.bz2 Hi, http://sources.redhat.com/bugzilla/show_bug.cgi?id=11788 backtrace: https://bugzilla.redhat.com/attachment.cgi?id=429195 sometimes GDB can crash. I do not have a reproducible crash but at least valgrind complains: cat >cmd < * varobj.c (varobj_create): Replace variable old_fi with old_id, initialize it by null_frame_id, wrap its usage by get_frame_id, frame_id_p and frame_find_by_id. --- gdb/varobj.c 6 Aug 2010 14:17:56 -0000 1.159 +++ gdb/varobj.c 6 Aug 2010 14:19:17 -0000 @@ -537,7 +537,7 @@ varobj_create (char *objname, if (expression != NULL) { struct frame_info *fi; - struct frame_info *old_fi = NULL; + struct frame_id old_id = null_frame_id; struct block *block; char *p; enum varobj_languages lang; @@ -611,7 +611,7 @@ varobj_create (char *objname, var->root->frame = get_frame_id (fi); var->root->thread_id = pid_to_thread_id (inferior_ptid); - old_fi = get_selected_frame (NULL); + old_id = get_frame_id (get_selected_frame (NULL)); select_frame (fi); } @@ -639,8 +639,8 @@ varobj_create (char *objname, var->root->rootvar = var; /* Reset the selected frame */ - if (old_fi != NULL) - select_frame (old_fi); + if (frame_id_p (old_id)) + select_frame (frame_find_by_id (old_id)); } /* If the variable object name is null, that means this