From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 36872 invoked by alias); 3 Nov 2015 18:11:52 -0000 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 Received: (qmail 36825 invoked by uid 89); 3 Nov 2015 18:11:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: xyzzy.0x04.net Received: from xyzzy.0x04.net (HELO xyzzy.0x04.net) (109.74.193.254) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 03 Nov 2015 18:11:49 +0000 Received: from hogfather.0x04.net (89-65-84-110.dynamic.chello.pl [89.65.84.110]) by xyzzy.0x04.net (Postfix) with ESMTPS id 9E34F3FF05; Tue, 3 Nov 2015 19:12:04 +0100 (CET) Received: by hogfather.0x04.net (Postfix, from userid 1000) id 7745D5800C5; Tue, 3 Nov 2015 19:11:45 +0100 (CET) From: =?UTF-8?q?Marcin=20Ko=C5=9Bcielnicki?= To: uweigand@de.ibm.com, brobecker@adacore.com Cc: gdb-patches@sourceware.org, =?UTF-8?q?Marcin=20Ko=C5=9Bcielnicki?= Subject: [PATCH v2] gdb/record-full: Use xmalloc instead of alloca for temporary memory storage. Date: Tue, 03 Nov 2015 18:11:00 -0000 Message-Id: <1446574301-9461-1-git-send-email-koriakin@0x04.net> In-Reply-To: <20151103173650.GF4009@adacore.com> References: <20151103173650.GF4009@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SW-Source: 2015-11/txt/msg00124.txt.bz2 On the newly added s390 target, it's possible for a single instruction to write practically unbounded amount of memory (eg. MVCLE). This caused a stack overflow when alloca was used. gdb/ChangeLog: * record-full.c (record_full_exec_insn): Use xmalloc for temporary memory storage. --- Done and done. gdb/ChangeLog | 5 +++++ gdb/record-full.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 532535d..5b20fa2 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2015-11-03 Marcin Kościelnicki + * record-full.c (record_full_exec_insn): Use xmalloc for temporary + memory storage. + +2015-11-03 Marcin Kościelnicki + * MAINTAINERS (Write After Approval): Add Marcin Kościelnicki. 2015-10-30 Pedro Alves diff --git a/gdb/record-full.c b/gdb/record-full.c index 595e357..03b3d41 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -726,7 +726,8 @@ record_full_exec_insn (struct regcache *regcache, /* Nothing to do if the entry is flagged not_accessible. */ if (!entry->u.mem.mem_entry_not_accessible) { - gdb_byte *mem = (gdb_byte *) alloca (entry->u.mem.len); + gdb_byte *mem = (gdb_byte *) xmalloc (entry->u.mem.len); + struct cleanup *cleanup = make_cleanup (xfree, mem); if (record_debug > 1) fprintf_unfiltered (gdb_stdlog, @@ -771,6 +772,8 @@ record_full_exec_insn (struct regcache *regcache, record_full_stop_reason = TARGET_STOPPED_BY_WATCHPOINT; } } + + do_cleanups (cleanup); } } break; -- 2.6.2