From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: gdb-patches@sourceware.org
Subject: [patch] Fix crash on NULL rl_prompt
Date: Mon, 29 Mar 2010 23:40:00 -0000 [thread overview]
Message-ID: <20100329234026.GA23895@host0.dyn.jankratochvil.net> (raw)
Hi,
https://bugzilla.redhat.com/attachment.cgi?id=401527
#1 in xstrdup (s=0x0) at ../../libiberty/xstrdup.c:33
#2 in tui_prep_terminal (notused1=1) at ../../gdb/tui/tui-io.c:292
#3 in _rl_callback_newline () at ../callback.c:82
#4 in gdb_do_one_event (data=0x0) at ../../gdb/event-loop.c:468
#5 in catch_errors (func=0x8177e60 <gdb_do_one_event>,
#6 in tui_command_loop
#7 in current_interp_command_loop
#8 in captured_command_loop
#9 in catch_errors
#10 in captured_main
#11 in catch_errors
#12 in gdb_main
#13 in main
I have not found how to reproduce it, normally when GDB calls
tui_prep_terminal it has rl_prompt set to non-NULL. But NULL rl_prompt is
a valid state for readline and GDB itself even sets it temporarily to NULL in
tui_setup_io (1) (just tui_prep_terminal is not called in such case) so I find
it fragile to crash on NULL rl_prompt. GDB can handle NULL
tui_rl_saved_prompt.
BTW don't you think xstrdup (NULL) should == NULL? Like xmalloc (0) == NULL.
No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu.
Thanks,
Jan
2010-03-30 Jan Kratochvil <jan.kratochvil@redhat.com>
* tui/tui-io.c (tui_prep_terminal): Permit NULL rl_prompt.
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -289,7 +289,10 @@ tui_prep_terminal (int notused1)
(we can't use gdb_prompt() due to secondary prompts and can't use
rl_prompt because it points to an alloca buffer). */
xfree (tui_rl_saved_prompt);
- tui_rl_saved_prompt = xstrdup (rl_prompt);
+ if (rl_prompt)
+ tui_rl_saved_prompt = xstrdup (rl_prompt);
+ else
+ tui_rl_saved_prompt = NULL;
}
/* Readline callback to restore the terminal. It is called once each
next reply other threads:[~2010-03-29 23:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-29 23:40 Jan Kratochvil [this message]
2010-03-30 15:57 ` Tom Tromey
2010-03-30 16:12 ` Pedro Alves
2010-03-30 16:23 ` Tom Tromey
2010-03-30 16:41 ` Pedro Alves
2010-03-30 17:05 ` Jan Kratochvil
2010-03-30 17:13 ` Tom Tromey
2010-03-30 17:25 ` Pedro Alves
2010-03-30 17:29 ` Jan Kratochvil
2010-03-30 17:55 ` Pedro Alves
2010-03-31 21:27 ` [cancel] " Jan Kratochvil
2010-03-30 17:31 ` Tom Tromey
2010-03-30 20:50 ` Pedro Alves
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=20100329234026.GA23895@host0.dyn.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=gdb-patches@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