From: "Marcin Kościelnicki" <koriakin@0x04.net>
To: uweigand@de.ibm.com, brobecker@adacore.com
Cc: gdb-patches@sourceware.org, "Marcin Kościelnicki" <koriakin@0x04.net>
Subject: [PATCH v2] gdb/record-full: Use xmalloc instead of alloca for temporary memory storage.
Date: Tue, 03 Nov 2015 18:11:00 -0000 [thread overview]
Message-ID: <1446574301-9461-1-git-send-email-koriakin@0x04.net> (raw)
In-Reply-To: <20151103173650.GF4009@adacore.com>
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 <koriakin@0x04.net>
+ * record-full.c (record_full_exec_insn): Use xmalloc for temporary
+ memory storage.
+
+2015-11-03 Marcin KoÅcielnicki <koriakin@0x04.net>
+
* MAINTAINERS (Write After Approval): Add Marcin KoÅcielnicki.
2015-10-30 Pedro Alves <palves@redhat.com>
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
next prev parent reply other threads:[~2015-11-03 18:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-02 18:42 [PATCH] gdb/record-full: Use xmalloc instead of alloca for large buffers Marcin Kościelnicki
2015-11-03 17:31 ` Ulrich Weigand
2015-11-03 17:36 ` Joel Brobecker
2015-11-03 18:11 ` Marcin Kościelnicki [this message]
2015-11-04 14:21 ` [PATCH v2] gdb/record-full: Use xmalloc instead of alloca for temporary memory storage Ulrich Weigand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1446574301-9461-1-git-send-email-koriakin@0x04.net \
--to=koriakin@0x04.net \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=uweigand@de.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox