public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "john dot wright at hp dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/10684] gdb crashes when given enough multiline input
Date: Tue, 22 Sep 2009 23:55:00 -0000	[thread overview]
Message-ID: <20090922235536.15445.qmail@sourceware.org> (raw)
In-Reply-To: <20090922234523.10684.john.wright@hp.com>


------- Additional Comments From john dot wright at hp dot com  2009-09-22 23:55 -------
(Sorry for lack of original description - I hit enter accidentally.)

If you enter a long multi-line command in gdb, it will often crash.  I'm
attaching an expect script that consistently crashes gdb for me (both on
Debian's version 6.8-3 and 6.8.50.20090628-4, and on CVS head
(7.0.50.20090922-cvs), on amd64 and i386.

The problem seems to be an strdup in command_line_handler in gdb/event-top.c
that uses a source that is not nul-terminated.  If the last line of the input is
a backslash, it copies the current linebuffer into the global
readline_input_state.linebuffer using strdup, and sets the global more_to_come
to 1.  Next time that function is called, it sees more_to_come is true, and
strcpy's readline_input_state.linebuffer into linebuffer -- but linebuffer has
been allocated to something smaller than what's in readline_input_state, since
it was strdup'd from a string that wasn't nul-terminated.  Eventually
(especially if you continue the line enough times), this will corrupt the heap
and cause gdb to crash.

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=10684

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


  reply	other threads:[~2009-09-22 23:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-22 23:45 [Bug gdb/10684] New: " john dot wright at hp dot com
2009-09-22 23:55 ` john dot wright at hp dot com [this message]
2009-09-23  0:05 ` [Bug gdb/10684] " john dot wright at hp dot com
2009-09-23  0:12 ` john dot wright at hp dot com
2009-09-23 17:27 ` cvs-commit at gcc dot gnu dot org
2009-09-23 17:33 ` cvs-commit at gcc dot gnu dot org
2009-09-23 17:34 ` tromey at redhat dot com

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=20090922235536.15445.qmail@sourceware.org \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).