From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26147 invoked by alias); 23 Dec 2009 22:48:25 -0000 Received: (qmail 26139 invoked by uid 22791); 23 Dec 2009 22:48:24 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS 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; Wed, 23 Dec 2009 22:48:18 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBNMmHai009280 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 23 Dec 2009 17:48:17 -0500 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBNMmEja010341 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 23 Dec 2009 17:48:16 -0500 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.3) with ESMTP id nBNMmEnD024887 for ; Wed, 23 Dec 2009 23:48:14 +0100 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.3/Submit) id nBNMmEnB024886 for gdb-patches@sourceware.org; Wed, 23 Dec 2009 23:48:14 +0100 Date: Wed, 23 Dec 2009 22:48:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch] related_breakpoint stale ref crash fix Message-ID: <20091223224814.GA24272@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-08-17) 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: 2009-12/txt/msg00364.txt.bz2 Hi, getting occasional random: PASS: gdb.threads/local-watch-wrong-thread.exp: local watchpoint still triggers PASS: gdb.threads/local-watch-wrong-thread.exp: let thread_function0 return PASS: gdb.threads/local-watch-wrong-thread.exp: breakpoint on thread_function0's caller -PASS: gdb.threads/local-watch-wrong-thread.exp: local watchpoint automatically deleted +ERROR: Process no longer exists +UNRESOLVED: gdb.threads/local-watch-wrong-thread.exp: local watchpoint automatically deleted It is even reproducible on HEAD using "input" file below and: valgrind ../gdb -nx type == bp_none) return; [...] bpt->type = bp_none; xfree (bpt); } While fixing this part may be difficult I find the attached patch easy enough fixing the IMO currently most common crash due to it. No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu. Thanks, Jan "input": set height 0 set width 0 set confirm no file ../testsuite/gdb.threads/local-watch-wrong-thread set can-use-hw-watchpoints 1 break main run break local-watch-wrong-thread.c:36 continue delete breakpoints watch *myp continue delete breakpoints echo MAKE watch\n watch *myp if trigger != 0 echo MAKE break\n break local-watch-wrong-thread.c:60 info break continue echo DELETE five\n delete 5 set trigger=1 continue set *myp=0 break local-watch-wrong-thread.c:47 continue 2009-12-23 Jan Kratochvil * breakpoint.c (delete_breakpoint related_breakpoint != NULL>): New. --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8649,6 +8649,16 @@ delete_breakpoint (struct breakpoint *bpt) if (bpt->type == bp_none) return; + /* At least avoid this stale reference until the reference counting of + breakpoints gets resolved. */ + if (bpt->related_breakpoint != NULL) + { + gdb_assert (bpt->related_breakpoint->related_breakpoint == bpt); + bpt->related_breakpoint->disposition = disp_del_at_next_stop; + bpt->related_breakpoint->related_breakpoint = NULL; + bpt->related_breakpoint = NULL; + } + observer_notify_breakpoint_deleted (bpt->number); if (breakpoint_chain == bpt)