]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[gdb/tui] Make tui_setup_io more robust
authorTom de Vries <tdevries@suse.de>
Thu, 2 Apr 2026 21:09:09 +0000 (23:09 +0200)
committerTom de Vries <tdevries@suse.de>
Thu, 2 Apr 2026 21:09:09 +0000 (23:09 +0200)
commitb171f68e9450e3bba074b0fe918b78c2ebb03af8
treeb7c09b0159b2643ff2f255fd011f6178261c6456
parent51308ff6a04565df30ff8a0c719ac1c1ed369f8b
[gdb/tui] Make tui_setup_io more robust

The following sequence of events may happen when enabling TUI:
- tui_enable () is called,
- a SIGFPE happens, before tui_setup_io (1) is called,
- the SIGFPE triggers handle_fatal_signal, which calls tui_disable (),
- during tui_disable (), tui_setup_io (0) is called, and
- tui_setup_io (0) tries to restore things that were saved during a previous
  tui_setup_io (1) call, but tui_setup_io (1) was never called so the saving
  never happened.

This can cause current_ui.m_ui_stderr to be nullptr, which then can cause a
crash in sig_write (PR33918).

Fix this by:
- adding a variable tui_io_mode, and
- using the variable to bail out of tui_setup_io in case the current mode
  doesn't change.

Tested on x86_64-linux.

Approved-By: Andrew Burgess <aburgess@redhat.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33918
gdb/tui/tui-io.c