Fix crash when exiting TUI with gdb -tui
authorTom Tromey <tom@tromey.com>
Tue, 16 Jun 2020 23:55:57 +0000 (17:55 -0600)
committerTom Tromey <tom@tromey.com>
Wed, 17 Jun 2020 00:02:20 +0000 (18:02 -0600)
commita350efd4fb368a35ada608f6bc26ccd3bed0ae6b
treea0f33da8020b08e20d56e414ae82a06c9c0ed7e6
parent39ec04904ff172dd67fd43ed3720f26d854732bf
Fix crash when exiting TUI with gdb -tui

PR tui/25348 points out that, when "gdb -tui" is used, then exiting
the TUI will cause a crash.

This happens because tui_setup_io stashes some readline variables --
but because this happens before readline is initialized, some of these
are NULL.  Then, when exiting the TUI, the NULL values are "restored",
causing a crash in readline.

This patch fixes the problem by ensuring that readline is initialized
first.  Back in commit 11061048d ("Give a name to the TUI SingleKey
keymap"), a call to rl_initialize was removed from
tui_initialize_readline; this patch resurrects the call, but moves it
to the end of the function, so as not to remove the ability to modify
the SingleKey map from .inputrc.

gdb/ChangeLog
2020-06-16  Tom Tromey  <tom@tromey.com>

PR tui/25348:
* tui/tui.c (tui_ensure_readline_initialized): Rename from
tui_initialize_readline.  Only run once.  Call rl_initialize.
* tui/tui.h (tui_ensure_readline_initialized): Rename from
tui_initialize_readline.
* tui/tui-io.c (tui_setup_io): Call
tui_ensure_readline_initialized.
* tui/tui-interp.c (tui_interp::init): Update.
gdb/ChangeLog
gdb/tui/tui-interp.c
gdb/tui/tui-io.c
gdb/tui/tui.c
gdb/tui/tui.h
This page took 0.043642 seconds and 4 git commands to generate.