From patchwork Tue Feb 16 08:17:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 10873 Received: (qmail 64451 invoked by alias); 16 Feb 2016 08:17:21 -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 64420 invoked by uid 89); 16 Feb 2016 08:17:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=347, sk:readvr, sk:readv-r, UD:readv-reverse.exp X-HELO: mail-pa0-f47.google.com Received: from mail-pa0-f47.google.com (HELO mail-pa0-f47.google.com) (209.85.220.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 16 Feb 2016 08:17:19 +0000 Received: by mail-pa0-f47.google.com with SMTP id fy10so59880508pac.1 for ; Tue, 16 Feb 2016 00:17:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=iBfpIvBVkfST1ANN9CIspopBOTd4d6Ad2Ftmf8LQq/E=; b=BNeuN/qKDIjUnof6tpY1lqgWs1YRuML0lekyIbYhVxYUj/KBm2UlB46RjWEmFVUE6f Yl0hrSrFxZIcPrgpAM7HS+gwqwlIB8Q8MRX9P2pK8KSEfLh5NfGn+I1lpgn0rBEbSFcz nFAEON1e8k8wSrn5q3HdKm/JAyJ9UOqpG3K27meu3L/H3Q8HOQhN073NQrTSc52w4ZPC s6wxNKyTQ0If0FALuy1Mh5Qum+F/2v72WsXIfRr4jummhbNILmUcN27b+X5H9REl2yk/ oE1hqg1jyMttiBzfGtoSuC6G15TxyoYCZdqLCHuzkKH4fSzE6SfmynLz4XL6mxY14ekA VRbg== X-Gm-Message-State: AG10YOSg4piLnvEySqBkhzWV65vs/KSU7qsLKAIeVFVktJvE8js5oHOy6KxOPMnE4jyBiQ== X-Received: by 10.66.150.170 with SMTP id uj10mr29075350pab.91.1455610637559; Tue, 16 Feb 2016 00:17:17 -0800 (PST) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id o90sm43657997pfi.17.2016.02.16.00.17.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Feb 2016 00:17:17 -0800 (PST) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH mainline/7.11] Fix cleanup in arm_linux_software_single_step Date: Tue, 16 Feb 2016 08:17:13 +0000 Message-Id: <1455610633-11019-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes I see the following error in testing aarch64 GDB debugging arm program. (gdb) PASS: gdb.reverse/readv-reverse.exp: set breakpoint at marker2 continue Continuing. ================================================================= ==32273==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x000000ce4c00 in thread T0 #0 0x2ba5615645c7 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x545c7)^M #1 0x4be8b5 in VEC_CORE_ADDR_cleanup /home/yao/SourceCode/gnu/gdb/git/gdb/common/gdb_vecs.h:34^M #2 0x5e6d95 in do_my_cleanups /home/yao/SourceCode/gnu/gdb/git/gdb/common/cleanups.c:154^M #3 0x64c99a in fetch_inferior_event /home/yao/SourceCode/gnu/gdb/git/gdb/infrun.c:3975^M #4 0x678437 in inferior_event_handler /home/yao/SourceCode/gnu/gdb/git/gdb/inf-loop.c:44^M #5 0x5078f6 in remote_async_serial_handler /home/yao/SourceCode/gnu/gdb/git/gdb/remote.c:13223^M #6 0x4cecfd in run_async_handler_and_reschedule /home/yao/SourceCode/gnu/gdb/git/gdb/ser-base.c:137^M #7 0x676864 in gdb_wait_for_event /home/yao/SourceCode/gnu/gdb/git/gdb/event-loop.c:834^M #8 0x676a27 in gdb_do_one_event /home/yao/SourceCode/gnu/gdb/git/gdb/event-loop.c:323^M #9 0x676aed in start_event_loop /home/yao/SourceCode/gnu/gdb/git/gdb/event-loop.c:347^M #10 0x6706d2 in captured_command_loop /home/yao/SourceCode/gnu/gdb/git/gdb/main.c:318^M #11 0x66db8c in catch_errors /home/yao/SourceCode/gnu/gdb/git/gdb/exceptions.c:240^M #12 0x6716dd in captured_main /home/yao/SourceCode/gnu/gdb/git/gdb/main.c:1157^M #13 0x66db8c in catch_errors /home/yao/SourceCode/gnu/gdb/git/gdb/exceptions.c:240^M #14 0x671b7a in gdb_main /home/yao/SourceCode/gnu/gdb/git/gdb/main.c:1165^M #15 0x467684 in main /home/yao/SourceCode/gnu/gdb/git/gdb/gdb.c:32^M #16 0x2ba563ed7ec4 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4)^M #17 0x4676b2 (/scratch/yao/gdb/build-git/aarch64-linux-gnu/gdb/gdb+0x4676b2) looks we should discard cleanup if function arm_linux_software_single_step returns early, or create cleanup when it is needed. Regressiontested on aarch64-linux. I'll push it in to mainline and 7.11 branch. gdb: 2016-02-15 Yao Qi * arm-linux-tdep.c (arm_linux_software_single_step): Assign 'old_chain' later. --- gdb/arm-linux-tdep.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c index 055a042..8954e11 100644 --- a/gdb/arm-linux-tdep.c +++ b/gdb/arm-linux-tdep.c @@ -934,13 +934,15 @@ arm_linux_software_single_step (struct frame_info *frame) CORE_ADDR pc; int i; VEC (CORE_ADDR) *next_pcs = NULL; - struct cleanup *old_chain = make_cleanup (VEC_cleanup (CORE_ADDR), &next_pcs); + struct cleanup *old_chain; /* If the target does have hardware single step, GDB doesn't have to bother software single step. */ if (target_can_do_single_step () == 1) return 0; + old_chain = make_cleanup (VEC_cleanup (CORE_ADDR), &next_pcs); + arm_get_next_pcs_ctor (&next_pcs_ctx, &arm_linux_get_next_pcs_ops, gdbarch_byte_order (gdbarch),