From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id SWI0FyLaaGlatAQAWB0awg (envelope-from ) for ; Thu, 15 Jan 2026 07:14:26 -0500 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=WMcrefou; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 5AE031E070; Thu, 15 Jan 2026 07:14:26 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,WEIRD_PORT autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 7C4331E070 for ; Thu, 15 Jan 2026 07:14:25 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 0B7B84BA2E1D for ; Thu, 15 Jan 2026 12:14:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0B7B84BA2E1D Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=WMcrefou Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 246844BA2E2E for ; Thu, 15 Jan 2026 12:13:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 246844BA2E2E Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 246844BA2E2E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1768479237; cv=none; b=icQ8SRxi+djt7G8bD4csWuFsJhqnYL0soXvDbHznzuImkIfw0tkBcSeYM0JvsTAU3iHpikmJMxr28GTZIJu4fHjzeISO3nhGZg14jPxJD+CgVROn7i2Q1Wmt1GN8SsunaHOcb4fd1IzjU14yPRA8g3x/5PODtrJ90dfd+zEbHQw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1768479237; c=relaxed/simple; bh=pOj/5jwwhUOwJbd/epqRzArxg8MwswPRG9tffRdmIyo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Egls5bE7RRva7lRlb+nqq5xSkVTZLzpuaEg6NoIrcI4Al5R0zZOyt2L2KkYNxGcStHrOpwc2LsGcrroxicgvvNKTOIrwdPhPdtEmgbfF9K1qxnc0wIiMIhXpMPJYTVY5NLB6ASS5jfBw62IICPX0Hb9myLVWjQfO49fW3uHSaHI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 246844BA2E2E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768479236; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zeCLgY/gsA/TqhY/e/rgxAvJt9B1vvaxsmdbaxPrklA=; b=WMcrefouxC37VMXQgvQ5Zv/CwtVjzlhYqOjS+lfa5D6xjXT9mF/UT/3sM3rcoFuxPA/9BN m24iN1hKhrdIIwEsM6nFOZFzeCrGDfnSnzOdjld/7sJfObrXdak1muSPA2/87QuOp+Ub9G 0WuDNBOJAe0S8XGbWOoKIZB5h4hnFQg= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-610-bDa0-DRmNpuHauZFmIxCcw-1; Thu, 15 Jan 2026 07:13:55 -0500 X-MC-Unique: bDa0-DRmNpuHauZFmIxCcw-1 X-Mimecast-MFC-AGG-ID: bDa0-DRmNpuHauZFmIxCcw_1768479234 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4801c632124so2614655e9.2 for ; Thu, 15 Jan 2026 04:13:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768479234; x=1769084034; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=q685LhsnAYcp3HOoDCFl1mpN4EOaOunU7CdLpDOxNhg=; b=Wo4xw/TaGIGGfssbhWt+KWrsXHyOV58HY/WRfglCgIV0dhaKGYMW4inQtoDiXR6HeV qDpxQCUqx7TlgP1kTrI21NqgsmAe/j8HhSqEX/bFgig+B3x0E7+zigfOE1V4V6Ka65nf SsWDQvRqCILF4En/FjBnLWU97KB2oS7z5yS0/bfjMk3flfV0VDHTVffFv3595N00lVn8 0vk3TpsRmBKTmCjGRQW0HNOyGWVTpVt88oUXd25scz03sZIfY01CRMeUm6PaBiq9r+9V ULl5fqY3KfHvj7jsOcQe4FCELhf10N+ZsecrMeXmpLyPU31zYrWCNOTm8jGGYklkER54 MUPA== X-Forwarded-Encrypted: i=1; AJvYcCUnot4tpFxY1uNerCL59YPdWj552MINf2OIfWpE9HxbUN+Cp1ZErnX2GmcOfpxqTE3jBhuMxz3GFlC/NQ==@sourceware.org X-Gm-Message-State: AOJu0YztqJJEH1vcowHtDAeCMGoz6pyFRxrjzNkejq1Iw0UIm3aCShC1 O9dA728R8HMDJ2TizgZ8vjg6c4FrGiTfJbUWPhvEHhgqIbMphpMnokKeh2Mfudw3b0WaMm43aop LGk5sImaDVvOhflowPWfk/hBtf/vwUEIM+bDe7dzwZenZtqfxaJ5Y8EMACFQQMO8q5gxZ1Ac= X-Gm-Gg: AY/fxX6GqbD83q40SwcFfj2UbJvBC/l2o4UMPJZTX/aAPZunlmh7XwGAdJhgnFN6h8a MTDoBTC3GzagCKTWDcGGyA/fW7rOtnCnFPjd4n7TRmrnKofrC3tCU6QS4KjjUL/l7b8HgUXuMXR Yw6vJdmoAzdu7YpqgAxO/SW8Yundm5mWzd2XqiyPYp3/i8o5Lpg7tm+UorWKjSeBjA5w4VQTsk7 AzUXQ0Kh99/96bOdM1yZUsUxh6FYJWV+fG3DpUUDvuf+cFtCk+MDUIBB9oAGX7unFB2L1yeod2e lyql4uzCaVnlAtdP38+xmC+14GteQ2YBeOYwuqGIqfKzWvqKrak82z+A0plqxb+Jk9xt2zp8K9N r18XxyIkttMn1MaInUwS50VDbU88J X-Received: by 2002:a05:600c:3d96:b0:477:76bf:e1fb with SMTP id 5b1f17b1804b1-47ee331113dmr80297365e9.16.1768479233937; Thu, 15 Jan 2026 04:13:53 -0800 (PST) X-Received: by 2002:a05:600c:3d96:b0:477:76bf:e1fb with SMTP id 5b1f17b1804b1-47ee331113dmr80297105e9.16.1768479233460; Thu, 15 Jan 2026 04:13:53 -0800 (PST) Received: from localhost (13.81.93.209.dyn.plus.net. [209.93.81.13]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47f428e5488sm45640875e9.14.2026.01.15.04.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jan 2026 04:13:53 -0800 (PST) From: Andrew Burgess To: Tom de Vries , gdb-patches@sourceware.org Subject: Re: [PATCH] [gdb/tui] Fix crash with debuginfod query In-Reply-To: <20260114172833.1824823-1-tdevries@suse.de> References: <20260114172833.1824823-1-tdevries@suse.de> Date: Thu, 15 Jan 2026 12:13:52 +0000 Message-ID: <87pl7bt6nz.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: TSe-vKRihSGELyL93nqTQ0LGd2kPG3VVFdDLqW85ziw_1768479234 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Tom de Vries writes: > PR tui/31449 reports a SIGFPE when the debuginfod query happens while enabling > TUI using the "tui enable" command: > ... > Thread 1 "gdb" received signal SIGFPE, Arithmetic exception. > 0x0000000001021084 in tui_inject_newline_into_command_window () > at /data/vries/gdb/src/gdb/tui/tui-io.c:1096 > 1096 py += px / tui_cmd_win ()->width; > ... > due to divide-by-zero because tui_cmd_win ()->width == 0. > > The corresponding backtrace is: > ... > (gdb) bt > #0 0x0000000001021084 in tui_inject_newline_into_command_window () > at gdb/tui/tui-io.c:1096 > #1 0x0000000000fe65fd in gdb_readline_wrapper_line (line=...) at gdb/top.c:939 > #2 0x0000000000944eef in gdb_rl_callback_handler (rl=0x2cc865a0 "n") > at gdb/event-top.c:288 > #3 0x0000000001175779 in rl_callback_read_char () > at readline/readline/callback.c:302 > #4 0x0000000000944bc3 in gdb_rl_callback_read_char_wrapper_sjlj () > at gdb/event-top.c:197 > #5 0x0000000000944cd4 in gdb_rl_callback_read_char_wrapper_noexcept () > at gdb/event-top.c:240 > #6 0x0000000000944d52 in gdb_rl_callback_read_char_wrapper (...) > at gdb/event-top.c:252 > #7 0x0000000001062352 in stdin_event_handler (error=0, client_data=0x2c865150) > at gdb/ui.c:154 > #8 0x0000000001a04edf in handle_file_event (file_ptr=0x2ccf8850, ready_mask=1) > at gdbsupport/event-loop.cc:551 > #9 0x0000000001a05522 in gdb_wait_for_event (block=1) > at gdbsupport/event-loop.cc:672 > #10 0x0000000001a043ff in gdb_do_one_event (mstimeout=-1) > at gdbsupport/event-loop.cc:263 > #11 0x00000000006d5480 in interp::do_one_event (this=0x2cc2af20, mstimeout=-1) > at gdb/interps.h:93 > #12 0x0000000000fe670d in gdb_readline_wrapper ( > prompt=0x2ccca4e0 "Enable debuginfod for this session? (y or [n]) ") > at gdb/top.c:1033 > #13 0x00000000010c6853 in defaulted_query(...) (...) > at gdb/utils.c:844 > #14 0x00000000010c6b8a in nquery (...) > at gdb/utils.c:901 > #15 0x00000000007a9324 in debuginfod_is_enabled () > at gdb/debuginfod-support.c:268 > #16 0x00000000007a950d in debuginfod_source_query (...) > at gdb/debuginfod-support.c:311 > #17 0x0000000000efc2c7 in open_source_file (s=0x2cc8f4b0) at gdb/source.c:1152 > #18 0x0000000000efc619 in symtab_to_fullname (...) at gdb/source.c:1214 > #19 0x0000000000f5ebb3 in find_line_symtab (...) > at gdb/symtab.c:3287 > #20 0x0000000000f5f0e5 in find_pc_for_line (...) > at gdb/symtab.c:3391 > #21 0x0000000001011f54 in tui_get_begin_asm_address (...) > at gdb/tui/tui-disasm.c:404 > #22 0x000000000104888d in tui_source_window_base::rerender (this=0x2cbdc570) > at gdb/tui/tui-winsource.c:474 > #23 0x0000000001028e81 in tui_win_info::resize (this=0x2cbdc570, > height_=21, width_=127, origin_x_=0, > origin_y_=0) at gdb/tui/tui-layout.c:299 > #24 0x00000000010297d0 in tui_layout_window::apply (this=0x2cc50350, > x_=0, y_=0, width_=127, > height_=21, preserve_cmd_win_size_p=false) at gdb/tui/tui-layout.c:432 > #25 0x000000000102bfea in tui_layout_split::apply (this=0x2caea920, > x_=0, y_=0, width_=127, > height_=33, preserve_cmd_win_size_p=false) at gdb/tui/tui-layout.c:1026 > #26 0x0000000001028267 in tui_apply_current_layout (...) > at gdb/tui/tui-layout.c:68 > #27 0x0000000001028737 in tui_set_layout (layout=0x2c9b9e90) > at gdb/tui/tui-layout.c:133 > #28 0x0000000001028af5 in tui_set_initial_layout () at gdb/tui/tui-layout.c:209 > #29 0x000000000104b795 in tui_enable () at gdb/tui/tui.c:496 > #30 0x000000000104bab3 in tui_enable_command (args=0x0, from_tty=1) > at gdb/tui/tui.c:591 > #31 0x00000000006c5ffe in do_simple_func (args=0x0, from_tty=1, c=0x2c9bb2f0) > at gdb/cli/cli-decode.c:94 > #32 0x00000000006cc94f in cmd_func (cmd=0x2c9bb2f0, args=0x0, from_tty=1) > at gdb/cli/cli-decode.c:2831 > #33 0x0000000000fe53ad in execute_command (p=0x2c86699a "", from_tty=1) > at gdb/top.c:563 > #34 0x000000000094584d in command_handler (command=0x2c866990 "tui enable") > at gdb/event-top.c:611 > #35 0x0000000000945dfe in command_line_handler (rl=...) at gdb/event-top.c:844 > #36 0x000000000101e916 in tui_command_line_handler (rl=...) > at gdb/tui/tui-interp.c:101 > #37 0x0000000000944eef in gdb_rl_callback_handler (rl=0x2cc86a30 "tui enable") > at gdb/event-top.c:288 > #38 0x0000000001175779 in rl_callback_read_char () > at readline/readline/callback.c:302 > #39 0x0000000000944bc3 in gdb_rl_callback_read_char_wrapper_sjlj () > at gdb/event-top.c:197 > #40 0x0000000000944cd4 in gdb_rl_callback_read_char_wrapper_noexcept () > at gdb/event-top.c:240 > #41 0x0000000000944d52 in gdb_rl_callback_read_char_wrapper (...) > at gdb/event-top.c:252 > #42 0x0000000001062352 in stdin_event_handler (error=0, client_data=0x2c865150) > at gdb/ui.c:154 > #43 0x0000000001a04edf in handle_file_event (file_ptr=0x2ccf8850, ready_mask=1) > at gdbsupport/event-loop.cc:551 > #44 0x0000000001a05522 in gdb_wait_for_event (block=1) > at gdbsupport/event-loop.cc:672 > #45 0x0000000001a043ff in gdb_do_one_event (mstimeout=-1) > at gdbsupport/event-loop.cc:263 > #46 0x00000000006d5480 in interp::do_one_event (this=0x2cc2af20, mstimeout=-1) > at gdb/interps.h:93 > #47 0x0000000000b77f25 in start_event_loop () at gdb/main.c:403 > #48 0x0000000000b78113 in captured_command_loop () at gdb/main.c:468 > #49 0x0000000000b7a07c in captured_main (context=0x7fff660b9e60) > at gdb/main.c:1381 > #50 0x0000000000b7a178 in gdb_main (args=0x7fff660b9e60) at gdb/main.c:1400 > #51 0x0000000000419705 in main (argc=5, argv=0x7fff660b9f98) at gdb/gdb.c:38 > (gdb) > ... > > The problem is that the command window is used (during initialization of the > source window) before it's properly initialized. > > A patch [1] was posted for this PR, which fixes the problem by calling > a function that will force the debuginfod query to happen before enabling the > TUI: > ... > static void > tui_enable_command (const char *args, int from_tty) > { > + /* Trigger any debuginfod-related y/n prompts now to avoid having > + it occur during tui initialization. Handling the prompt while > + tui windows are initializing can cause crashes. */ > + debuginfod_is_enabled (); > + > tui_enable (); > } > ... > > While that approach works fine, it requires us to hard-code each query that > may happen. > > [ A review comment reported a problem when using C-x C-a to enable TUI instead > of "tui enable", not fixed by the previous patch. It's also not fixed by this > patch. Filed as PR33794. ] > > This patch takes another approach: add a layout with only the command window, > and activate that layout first, making sure that we finalize the > initialization of the command window before we activate the initial layout. > > While that fixes the divide-by-zero, the query still looks slightly odd > because '\n' does a line feed but no a carriage return, so each new line has > more leading spaces. > > Fix this by moving the activation of the initial layout to after tui_setup_io. I don't really like the way that this change clears the screen and then displays just the debuginfod prompt, it feels a little odd. The problem appears to be our attempt to populate the TUI windows with content prior to having fully setup the initial TUI CMD window. So, I wondered, could we not just defer populating the windows maybe? As an absolute bodge just to see if this would work or not, I created the patch below. Reminder, this patch is 200% a hack. It really is just a "what might the user experience look like" proof of concept. This arranges for the source windows to not fill in any content while the initial layout is being setup, then, once the TUI is enabled, we rerender all the windows, filling in the content. In this way, the debuginfod prompt appears within the expected CMD window. What do you think about this as an end goal? Obviously the approach would need to be figured out, as the patch below is 300% hack (yes, it got worse while I'm thinking about it). Thanks, Andrew --- diff --git i/gdb/tui/tui-layout.c w/gdb/tui/tui-layout.c index 272f5134d85..903a22f3ad1 100644 --- i/gdb/tui/tui-layout.c +++ w/gdb/tui/tui-layout.c @@ -38,6 +38,8 @@ #include "tui/tui-source.h" #include "gdb_curses.h" +bool magic_disable = false; + /* The layouts. */ static std::vector> layouts; @@ -206,7 +208,9 @@ tui_next_layout_command (const char *arg, int from_tty) void tui_set_initial_layout () { + magic_disable = true; tui_set_layout (layouts[0].get ()); + magic_disable = false; } /* Implement the "layout prev" command. */ @@ -296,7 +300,8 @@ tui_win_info::resize (int height_, int width_, if (handle == nullptr) make_window (); - rerender (); + if (!magic_disable) + rerender (); } diff --git i/gdb/tui/tui.c w/gdb/tui/tui.c index fb94823f0fe..21e1d08ac8e 100644 --- i/gdb/tui/tui.c +++ w/gdb/tui/tui.c @@ -534,6 +534,7 @@ tui_enable (void) tui_set_key_mode (tui_current_key_mode); /* Refresh the screen. */ + tui_apply_current_layout (true); tui_refresh_all_win (); /* Update gdb's knowledge of its terminal. */ diff --git i/gdb/tui/tui.h w/gdb/tui/tui.h index 7daefe2c9bb..7760f62ddf3 100644 --- i/gdb/tui/tui.h +++ w/gdb/tui/tui.h @@ -22,6 +22,8 @@ #ifndef GDB_TUI_TUI_H #define GDB_TUI_TUI_H +extern bool magic_disable; + /* Flag to control tui debugging. */ extern bool debug_tui;