From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2269 invoked by alias); 22 Nov 2008 21:41:21 -0000 Received: (qmail 2182 invoked by uid 22791); 22 Nov 2008 21:41:18 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 22 Nov 2008 21:40:43 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id mAMLeClL030158 for ; Sat, 22 Nov 2008 16:40:12 -0500 Received: from pobox.stuttgart.redhat.com (pobox.stuttgart.redhat.com [172.16.2.10]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id mAMLeAWs018915 for ; Sat, 22 Nov 2008 16:40:12 -0500 Received: from host0.dyn.jankratochvil.net (sebastian-int.corp.redhat.com [172.16.52.221]) by pobox.stuttgart.redhat.com (8.13.1/8.13.1) with ESMTP id mAMLe9G4001089 for ; Sat, 22 Nov 2008 16:40:09 -0500 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.2) with ESMTP id mAMLe66T022229 for ; Sat, 22 Nov 2008 22:40:06 +0100 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.2/Submit) id mAMLe6pP022226 for gdb-patches@sourceware.org; Sat, 22 Nov 2008 22:40:06 +0100 Date: Mon, 24 Nov 2008 03:35:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch] Fix double free on error while inserting the breakpoint Message-ID: <20081122214006.GA22076@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="5mCyUwZo2JvN/JJP" Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-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: 2008-11/txt/msg00620.txt.bz2 --5mCyUwZo2JvN/JJP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 282 Hi, SEGV reproducer: x86 requires to build GDB with -lmcheck to make the crash reproducible. Therefore no testsuite testcase is provided. ./gdb -nx -ex start -ex 'set breakpoint always-inserted on' -ex 'b *0' -ex 'delete 2' ./gdb (Found on ia64 without -lmcheck.) Regards, Jan --5mCyUwZo2JvN/JJP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="gdb-breakpoint-free.patch" Content-length: 1340 2008-11-22 Jan Kratochvil Fix double free on error inserting the breakpoint instruction. * breakpoint.c (create_breakpoints): Move the update_global_location_list call to ... (break_command_really): ... here together with the second local call both unified after all the cleanups. --- gdb/breakpoint.c 22 Nov 2008 04:41:45 -0000 1.362 +++ gdb/breakpoint.c 22 Nov 2008 20:10:07 -0000 @@ -5257,8 +5257,6 @@ create_breakpoints (struct symtabs_and_l cond_string, type, disposition, thread, ignore_count, ops, from_tty); } - - update_global_location_list (1); } /* Parse ARG which is assumed to be a SAL specification possibly @@ -5579,7 +5577,6 @@ break_command_really (char *arg, char *c b->condition_not_parsed = 1; b->ops = ops; - update_global_location_list (1); mention (b); } @@ -5591,6 +5588,11 @@ break_command_really (char *arg, char *c discard_cleanups (breakpoint_chain); /* But cleanup everything else. */ do_cleanups (old_chain); + + /* Have already BREAKPOINT_CHAIN discarded as we may get an exception while + inserting the breakpoints which would double-free the resources both by + BREAKPOINT_CHAIN now and during DELETE_BREAKPOINT in the future. */ + update_global_location_list (1); } /* Set a breakpoint. --5mCyUwZo2JvN/JJP--