From patchwork Wed Jul 5 23:51:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 21445 Received: (qmail 112992 invoked by alias); 5 Jul 2017 23:51:16 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 112978 invoked by uid 89); 5 Jul 2017 23:51:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Jul 2017 23:51:14 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5BF3764A4B for ; Wed, 5 Jul 2017 23:51:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5BF3764A4B Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5BF3764A4B Received: from cascais.lan (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB9AF707CB for ; Wed, 5 Jul 2017 23:51:12 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [pushed] Fix Python unwinder frames regression Date: Thu, 6 Jul 2017 00:51:11 +0100 Message-Id: <1499298671-15852-1-git-send-email-palves@redhat.com> The gdb.python/py-unwind.exp test is crashing GDB / leaving core dumps in the test dir, even though it all passes cleanly. The crash is not visible in gdb.sum/gdb.log because it happens as side effect of the "quit" command, while flushing the frame cache. The problem is simply a typo in a 'for' loop's condition, introduced by a recent change [4fa847d78edd ("Remove MAX_REGISTER_SIZE from py-unwind.c")], resulting in infinite loop / double-free. The new test exposes the crash, like: Running src/gdb/testsuite/gdb.python/py-unwind.exp ... ERROR: Process no longer exists gdb/ChangeLog: 2017-07-06 Pedro Alves * python/py-unwind.c (pyuw_dealloc_cache): Fix for loop condition. gdb/testsuite/ChangeLog: 2017-07-06 Pedro Alves * gdb.python/py-unwind.exp: Test flushregs. --- gdb/ChangeLog | 4 ++++ gdb/testsuite/ChangeLog | 4 ++++ gdb/python/py-unwind.c | 2 +- gdb/testsuite/gdb.python/py-unwind.exp | 3 ++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 03f30af..7908142 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2017-07-06 Pedro Alves + + * python/py-unwind.c (pyuw_dealloc_cache): Fix for loop condition. + 2017-07-04 Pedro Alves * gdbtypes.c (recursive_dump_type): Don't reference TYPE_STATIC. diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 6160c4b..d6a7252 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-07-06 Pedro Alves + + * gdb.python/py-unwind.exp: Test flushregs. + 2017-06-30 Sergio Durigan Junior PR cli/21688 diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c index 1d800a7..acfce7d 100644 --- a/gdb/python/py-unwind.c +++ b/gdb/python/py-unwind.c @@ -595,7 +595,7 @@ pyuw_dealloc_cache (struct frame_info *this_frame, void *cache) TRACE_PY_UNWIND (3, "%s: enter", __FUNCTION__); cached_frame_info *cached_frame = (cached_frame_info *) cache; - for (int i = 0; cached_frame->reg_count; i++) + for (int i = 0; i < cached_frame->reg_count; i++) xfree (cached_frame->reg[i].data); xfree (cache); diff --git a/gdb/testsuite/gdb.python/py-unwind.exp b/gdb/testsuite/gdb.python/py-unwind.exp index 0a4d34f..625b04c 100644 --- a/gdb/testsuite/gdb.python/py-unwind.exp +++ b/gdb/testsuite/gdb.python/py-unwind.exp @@ -51,4 +51,5 @@ gdb_test_sequence "where" "Backtrace restored by unwinder" { "\\r\\n#2 .* main \\(.*\\) at" } - +# Check that the Python unwinder frames can be flushed / released. +gdb_test "flushregs" "Register cache flushed\\." "flush frames"