From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30618 invoked by alias); 2 Mar 2008 08:41:22 -0000 Received: (qmail 30609 invoked by uid 22791); 2 Mar 2008 08:41:21 -0000 X-Spam-Check-By: sourceware.org Received: from host0.dyn.jankratochvil.net (HELO host0.dyn.jankratochvil.net) (89.250.240.59) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 02 Mar 2008 08:40:54 +0000 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.2/8.14.1) with ESMTP id m228eoff023630 for ; Sun, 2 Mar 2008 09:40:51 +0100 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.2/8.14.2/Submit) id m228eoKL023629 for gdb-patches@sourceware.org; Sun, 2 Mar 2008 09:40:50 +0100 Date: Sun, 02 Mar 2008 08:41:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch] Fix segfault on a failed watchpoint update Message-ID: <20080302084050.GA22521@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="PNTmBPCT7hxwcZjr" Content-Disposition: inline User-Agent: Mutt/1.5.17 (2007-11-01) 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-03/txt/msg00004.txt.bz2 --PNTmBPCT7hxwcZjr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 3222 Hi, currently GDB HEAD segfaults during one case for the PIE inferiors (failing as it is the unpatched CVS HEAD), segfault fix attached. Regards, Jan crash reproducibility: $ runtest --target_board=unix/-fPIE/-pie gdb.base/watchpoint.exp WARNING: Couldn't find the global config file. Test Run By jkratoch on Sun Mar 2 09:31:14 2008 Native configuration is x86_64-unknown-linux-gnu === gdb tests === Schedule of variations: unix/-fPIE/-pie Running target unix/-fPIE/-pie Using /usr/share/dejagnu/baseboards/unix.exp as board description file for target. Using /usr/share/dejagnu/config/unix.exp as generic interface file for target. Using ../.././gdb/testsuite/config/unix.exp as tool-and-target-specific interface file. Running ../.././gdb/testsuite/gdb.base/watchpoint.exp ... FAIL: gdb.base/watchpoint.exp: run to marker1 in test_simple_watchpoint ERROR: Process no longer exists ERROR: Couldn't send disable 3 to GDB. ERROR: Delete all breakpoints in delete_breakpoints (timeout) ERROR: Delete all breakpoints in delete_breakpoints (timeout) FAIL: gdb.base/watchpoint.exp: watch tests suppressed FAIL: gdb.base/watchpoint.exp: (timeout) disable fast watches FAIL: gdb.base/watchpoint.exp: (timeout) show disable fast watches FAIL: gdb.base/watchpoint.exp: (timeout) set slow conditional watch FAIL: gdb.base/watchpoint.exp: (timeout) trigger slow conditional watch FAIL: gdb.base/watchpoint.exp: (timeout) rwatch disallowed when can-use-hw-watchpoints cleared ERROR: Delete all breakpoints in delete_breakpoints (timeout) === gdb Summary === # of expected passes 7 # of unexpected failures 7 # of unresolved testcases 5 .../sources/gdb/testsuite/../../gdb/gdb version 6.8.50.20080302-cvs -nx ... (gdb) PASS: gdb.base/watchpoint.exp: disable watchpoint in test_simple_watchpoint run Starting program: /home/jkratoch/redhat/sources/gdb/testsuite/gdb.base/watchpoint Error in re-setting breakpoint 1: Cannot access memory at address 0x86c Error in re-setting breakpoint 2: Cannot access memory at address 0x872 Error in re-setting breakpoint 3: Cannot access memory at address 0x20127c Error in re-setting breakpoint 1: Cannot access memory at address 0x86c Error in re-setting breakpoint 2: Cannot access memory at address 0x872 Error in re-setting breakpoint 3: Cannot access memory at address 0x20127c Error in re-setting breakpoint 1: Cannot access memory at address 0x86c Error in re-setting breakpoint 2: Cannot access memory at address 0x872 Error in re-setting breakpoint 3: Cannot access memory at address 0x20127c Program exited normally. (gdb) FAIL: gdb.base/watchpoint.exp: run to marker1 in test_simple_watchpoint info watch *** glibc detected *** /home/jkratoch/redhat/sources/gdb/testsuite/../../gdb/gdb: double free or corruption (!prev): 0x00000000023f9d20 *** ======= Backtrace: ========= /lib64/libc.so.6[0x3b98672832] /lib64/libc.so.6(cfree+0x8c)[0x3b98675f2c] /home/jkratoch/redhat/sources/gdb/testsuite/../../gdb/gdb(xfree+0x1c)[0x44efb6] /home/jkratoch/redhat/sources/gdb/testsuite/../../gdb/gdb(free_all_values+0x2a)[0x4cd65a] /home/jkratoch/redhat/sources/gdb/testsuite/../../gdb/gdb(execute_command+0x26)[0x44b9df] ... --PNTmBPCT7hxwcZjr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="gdb-value-update_watchpoint-exception.patch" Content-length: 1045 2008-03-02 Jan Kratochvil * breakpoint.c (update_watchpoint): Move B->VAL setting behind the VALUE_CONTENTS call. --- ./gdb/breakpoint.c 27 Feb 2008 20:27:49 -0000 1.304 +++ ./gdb/breakpoint.c 2 Mar 2008 08:27:20 -0000 @@ -913,13 +917,15 @@ update_watchpoint (struct breakpoint *b, during evaluation, and set watchoints at addresses as needed. Those values are explicitly deleted here. */ v = evaluate_expression (b->exp); + /* Fetch the value first as if ti fails and breaks out by the exception + there will be no stale V left in B->VAL. */ + value_contents (v); /* Avoid setting b->val if it's already set. The meaning of b->val is 'the last value' user saw, and we should update it only if we reported that last value to user. As it happens, the code that reports it updates b->val directly. */ if (b->val == NULL) b->val = v; - value_contents (v); value_release_to_mark (mark); /* Look at each value on the value chain. */ --PNTmBPCT7hxwcZjr--