From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 7TeGCu6uD2hhigoAWB0awg (envelope-from ) for ; Mon, 28 Apr 2025 12:38:06 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=jwX7PAgS; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=w+J6zpKA; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=DcoNUHTa; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Ezw5U0so; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 19A601E10E; Mon, 28 Apr 2025 12:38:06 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,WEIRD_PORT autolearn=unavailable autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (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 4ACF71E0C0 for ; Mon, 28 Apr 2025 12:38:05 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DA22D3858C60 for ; Mon, 28 Apr 2025 16:38:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DA22D3858C60 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=jwX7PAgS; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=w+J6zpKA; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=DcoNUHTa; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Ezw5U0so Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id 6BF603858D3C for ; Mon, 28 Apr 2025 16:32:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6BF603858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6BF603858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745857939; cv=none; b=omKfXHmKVUgCCsO46yqylMaICa1YlLornZR4CrHgfe23cxR9UnaR4lGz2S6EWH3mSBtk1vXknz2qhcwnN9RP+QkVmjJVyX1XLH7o8q32w2T8Wc0XpgISDIWurKUCuvPdqMiakdptb1dOQ0kId6V9as5jvQqM7C28+G4pEYjeiQk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745857939; c=relaxed/simple; bh=e73IxvVft1Ffgqn96/58s7OfYnRzstPRPH5YdNHDIxE=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:To:From; b=MX1j2bs6A1n9rQLmXiL9Y34qHI7L4Z4YLc9qIaWRb/vxfweNLvfUtgHMFtvBhutgvjDDOUvBjBcoMWxMrjkpeGib3S7aL2DlL8n+WCVoWJWi8AKDydrch1wd6n5YYzxFJQP8vxUmFZZDIFg5P5Co2Oo50xu8HBrhO7eRnmC8crY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6BF603858D3C Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 375481F395; Mon, 28 Apr 2025 16:32:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1745857937; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CG1FWUqrKd3F0FuZEuvV3RUUjpMWSv2b5L/Tlx2Mjdc=; b=jwX7PAgSlNbY9wIs1nT3w4QUHZoMTQ1G+aVz3cXwSQQD+gj2UE1Rl6z8Q1w7B3FnJzLS1A d4TMMT2hRm88H8esCIQfnwcygRwJAHSgWt1BOOWfDdUcjCDa21Jr047SnlOdAoYPSN4U1s nlSqDPE57y/hFKCmkE4JH5ibLzP6ukA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1745857937; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CG1FWUqrKd3F0FuZEuvV3RUUjpMWSv2b5L/Tlx2Mjdc=; b=w+J6zpKAbmhKmc4NNiegrul+Wfc8olds3Geaa1fOkb9zzqNeRT8iEKcFNaZ07/ktqpyqeq UIH/AGc+2c02sSDQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=DcoNUHTa; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Ezw5U0so DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1745857936; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CG1FWUqrKd3F0FuZEuvV3RUUjpMWSv2b5L/Tlx2Mjdc=; b=DcoNUHTaW2ECFWsHu9HBlh/rj4j2stXUVgd0EYP1YDaUBRl67hmTijnH6zMHRhAQ3nLOFZ 6B2dOyQ8go2Ly5ALdtLaD/900vvJhAtHSHLEGsq74lnAqAAsPp1lO2QLbFZ+qUfUBfspBc /bJDem8HH5Ylu4rOuzGDBrkh0e+VPFY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1745857936; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CG1FWUqrKd3F0FuZEuvV3RUUjpMWSv2b5L/Tlx2Mjdc=; b=Ezw5U0sovcc9uA8ky1g1dCieOyCAQb0380Xhi4xmUrefJu4gk2GcXCHHxDHlHsOaO3mgI0 o+LHfDPMEGWzxACw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 189391336F; Mon, 28 Apr 2025 16:32:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id YNXWA5CtD2h9HAAAD6G6ig (envelope-from ); Mon, 28 Apr 2025 16:32:16 +0000 Message-ID: <74728484-0770-408b-b877-2b6f827d1e2c@suse.de> Date: Mon, 28 Apr 2025 18:32:19 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] [gdb] Handle nullptr stream in gdb_flush To: Simon Marchi , gdb-patches@sourceware.org References: <20250425171845.9934-1-tdevries@suse.de> <20250425171845.9934-3-tdevries@suse.de> <0eedfe61-5b44-45c2-806c-493f75bb881b@simark.ca> Content-Language: en-US From: Tom de Vries In-Reply-To: <0eedfe61-5b44-45c2-806c-493f75bb881b@simark.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 375481F395 X-Rspamd-Action: no action X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_VIA_SMTP_AUTH(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:dkim,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,gnu.org:url]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org 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 On 4/28/25 17:21, Simon Marchi wrote: > On 4/25/25 1:18 PM, Tom de Vries wrote: >> Using the trigger patch described in the previous commit, I get: >> ... >> $ gdb >> (gdb) error detected on stdin >> >> Fatal signal: Segmentation fault >> ----- Backtrace ----- >> 0x64c7b3 gdb_internal_backtrace_1 >> /data/vries/gdb/src/gdb/bt-utils.c:127 >> 0x64c937 _Z22gdb_internal_backtracev >> /data/vries/gdb/src/gdb/bt-utils.c:196 >> 0x94db83 handle_fatal_signal >> /data/vries/gdb/src/gdb/event-top.c:1021 >> 0x94dd48 handle_sigsegv >> /data/vries/gdb/src/gdb/event-top.c:1098 >> 0x7f372be578ff ??? >> 0x10b7c0a _Z9gdb_flushP7ui_file >> /data/vries/gdb/src/gdb/utils.c:1527 >> 0xd4b938 gdbpy_flush >> /data/vries/gdb/src/gdb/python/python.c:1624 >> 0x7f372d73b276 _PyCFunction_FastCallDict >> Objects/methodobject.c:231 >> 0x7f372d73b276 _PyCFunction_FastCallKeywords >> Objects/methodobject.c:294 >> 0x7f372d794a09 call_function >> Python/ceval.c:4851 >> 0x7f372d78e838 _PyEval_EvalFrameDefault >> Python/ceval.c:3351 >> 0x7f372d796e6e PyEval_EvalFrameEx >> Python/ceval.c:754 >> 0x7f372d796e6e _PyFunction_FastCall >> Python/ceval.c:4933 >> 0x7f372d796e6e _PyFunction_FastCallDict >> Python/ceval.c:5035 >> 0x7f372d6fefc8 _PyObject_FastCallDict >> Objects/abstract.c:2310 >> 0x7f372d6fefc8 _PyObject_Call_Prepend >> Objects/abstract.c:2373 >> 0x7f372d6fe162 _PyObject_FastCallDict >> Objects/abstract.c:2331 >> 0x7f372d700705 callmethod >> Objects/abstract.c:2583 >> 0x7f372d700705 _PyObject_CallMethodId >> Objects/abstract.c:2640 >> 0x7f372d812a41 flush_std_files >> Python/pylifecycle.c:699 >> 0x7f372d81281d Py_FinalizeEx >> Python/pylifecycle.c:768 >> 0xd4d49b finalize_python >> /data/vries/gdb/src/gdb/python/python.c:2308 >> 0x9587eb _Z17ext_lang_shutdownv >> /data/vries/gdb/src/gdb/extension.c:330 >> 0xfd98df _Z10quit_forcePii >> /data/vries/gdb/src/gdb/top.c:1817 >> 0x6b3080 _Z12quit_commandPKci >> /data/vries/gdb/src/gdb/cli/cli-cmds.c:483 >> 0x1056577 stdin_event_handler >> /data/vries/gdb/src/gdb/ui.c:131 >> 0x1986970 handle_file_event >> /data/vries/gdb/src/gdbsupport/event-loop.cc:551 >> 0x1986f4b gdb_wait_for_event >> /data/vries/gdb/src/gdbsupport/event-loop.cc:672 >> 0x1985e0c _Z16gdb_do_one_eventi >> /data/vries/gdb/src/gdbsupport/event-loop.cc:263 >> 0xb66f2e start_event_loop >> /data/vries/gdb/src/gdb/main.c:402 >> 0xb670ba captured_command_loop >> /data/vries/gdb/src/gdb/main.c:466 >> 0xb68b9b captured_main >> /data/vries/gdb/src/gdb/main.c:1344 >> 0xb68c44 _Z8gdb_mainP18captured_main_args >> /data/vries/gdb/src/gdb/main.c:1363 >> 0x41a3b1 main >> /data/vries/gdb/src/gdb/gdb.c:38 >> --------------------- >> A fatal error internal to GDB has been detected, further >> debugging is not possible. GDB will now terminate. >> >> This is a bug, please report it. For instructions, see: >> . >> >> Segmentation fault (core dumped) >> $ q >> ... >> >> Fix this in gdb_flush by checking for nullptr stream parameter, such that we >> get instead: >> ... >> $ gdb >> (gdb) error detected on stdin >> $ q >> ... >> >> Tested on x86_64-linux. >> --- >> gdb/utils.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/gdb/utils.c b/gdb/utils.c >> index ce3c26ef140..90063e4a96d 100644 >> --- a/gdb/utils.c >> +++ b/gdb/utils.c >> @@ -1524,7 +1524,8 @@ pager_file::flush () >> void >> gdb_flush (struct ui_file *stream) >> { >> - stream->flush (); >> + if (stream != nullptr) >> + stream->flush (); > Hi Simon, thanks for the review. > Can we add the nullptr check only where it's needed? > AFAIU, I've added it where it's needed. Can you tell me where you think it's needed? I cannot tell from your comments. Thanks, - Tom > I'm thinking that we should move towards removing gdb_flush (replacing > the call sites to call ui_file::flush directly). And when we do so, we > wouldn't want to add nullptr checks everywhere that gdb_flush is > currently called. > > Simon