From patchwork Mon Aug 3 21:02:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 7988 Received: (qmail 52476 invoked by alias); 3 Aug 2015 21:02:12 -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 52466 invoked by uid 89); 3 Aug 2015 21:02:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=no version=3.3.2 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 03 Aug 2015 21:02:11 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 681B28F29B for ; Mon, 3 Aug 2015 21:02:10 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-116-41.ams2.redhat.com [10.36.116.41]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t73L26wu006777 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 3 Aug 2015 17:02:09 -0400 Date: Mon, 3 Aug 2015 23:02:05 +0200 From: Jan Kratochvil To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: [patch] ASAN attach crash - 7.9 regression [Re: [PATCH 4/4] PR gdb/17471: Repeating a background command makes it foreground] Message-ID: <20150803210205.GA2019@host1.jankratochvil.net> References: <1412877629-12052-1-git-send-email-palves@redhat.com> <1412877629-12052-5-git-send-email-palves@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1412877629-12052-5-git-send-email-palves@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes On Thu, 09 Oct 2014 20:00:29 +0200, Pedro Alves wrote: > Tested on x86_64 Fedora 20, native and gdbserver. -fsanitize=address gdb.base/attach-pie-noexec.exp ==32586==ERROR: AddressSanitizer: heap-use-after-free on address 0x60200004ed90 at pc 0x48ad50 bp 0x7ffceb3aef50 sp 0x7ffceb3aef20 READ of size 2 at 0x60200004ed90 thread T0 #0 0x48ad4f in __interceptor_strlen (/home/jkratoch/redhat/gdb-test-asan/gdb/gdb+0x48ad4f) #1 0xeafe5c in xstrdup xstrdup.c:33 #2 0x85e024 in attach_command /home/jkratoch/redhat/gdb-test-asan/gdb/infcmd.c:2680 regressed by: commit 6c4486e63f7583ed85a0c72841f6ccceebbf858e Author: Pedro Alves Date: Fri Oct 17 13:31:26 2014 +0100 PR gdb/17471: Repeating a background command makes it foreground OK for check-in and for 7.10? Jan 2015-08-03 Jan Kratochvil PR gdb/18767 * infcmd.c (attach_command): Move ARGS_CHAIN cleanup after last ARGS use. diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 4948d27..5cd8dd7 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -2617,9 +2617,6 @@ attach_command (char *args, int from_tty) shouldn't refer to attach_target again. */ attach_target = NULL; - /* Done with ARGS. */ - do_cleanups (args_chain); - /* Set up the "saved terminal modes" of the inferior based on what modes we are starting it with. */ target_terminal_init (); @@ -2684,12 +2681,19 @@ attach_command (char *args, int from_tty) a->async_exec = async_exec; add_inferior_continuation (attach_command_continuation, a, attach_command_continuation_free_args); + + /* Done with ARGS. */ + do_cleanups (args_chain); + return; } wait_for_inferior (); } + /* Done with ARGS. */ + do_cleanups (args_chain); + attach_command_post_wait (args, from_tty, async_exec); }