From patchwork Fri Oct 11 14:35:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 98737 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 608D7385AC36 for ; Fri, 11 Oct 2024 14:36:16 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id 7E3873858433 for ; Fri, 11 Oct 2024 14:35:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7E3873858433 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 7E3873858433 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=1728657345; cv=none; b=H82Drjt7ymQ/o1jbrJbAL7aywyUPNsxlqIK7aTq4cXvtwiajDwRic0Km6nocqx9ZaeGQqfvVlHSdnNoIBh5EywgLyqnC+OSTDUFghNkNpAxU25t/mOH75NJNvxk9izlcsTVArfbhmUWa49LIpDUbQ9ijgcpS7KXZmmitYXsFFwI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728657345; c=relaxed/simple; bh=QApNl3w2RmQ69BBlUuZ92ZTBfGKNKOQRyLl7IK2fKW0=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=oaeCHe8dfKXm9A5ES0n5W2ylRDV8c+s/BEljT+5CdenKxKuGmg9QD7c44rKb9UsNM4RvgtfN/na2Fc1/E5RyrqrgBhz4zXxC87x4sue8SC6Y/n8GlgfWzI1pw9QjyuCuY4e/NW4N1g+JDN0bXzS2KSnzXkCwbO7gtI0oC3Skb8o= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (unknown [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 9631A1FF0C for ; Fri, 11 Oct 2024 14:35:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728657342; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p0R16gg8DITio604nNfuG9oY9QF+gFSEJTr1f4hLcow=; b=1wPidTDDV7zDTYtOScEOO14wEdA7qhZirCpv1BMFAPPy934b8PD6oqCUF7F+uHhklT3Gax 6MbjJfrneFKiXAD0FQyT/q0EjxLzUvAoI0sw2BFdEVwBjVuvAc8D20TqfABkKAjLIrcxBp OhbcrNfVFbYqp+xvomuk8gUAqvuID0M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728657342; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p0R16gg8DITio604nNfuG9oY9QF+gFSEJTr1f4hLcow=; b=P2hwrjOfwGbOW/vFmpFinEKwCWDlW6Frj6UAnKHt39vJ5XT87hBZJyzns2l23xcDseO9T4 EWeCmgxeXdoTNFAQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728657342; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p0R16gg8DITio604nNfuG9oY9QF+gFSEJTr1f4hLcow=; b=1wPidTDDV7zDTYtOScEOO14wEdA7qhZirCpv1BMFAPPy934b8PD6oqCUF7F+uHhklT3Gax 6MbjJfrneFKiXAD0FQyT/q0EjxLzUvAoI0sw2BFdEVwBjVuvAc8D20TqfABkKAjLIrcxBp OhbcrNfVFbYqp+xvomuk8gUAqvuID0M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728657342; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p0R16gg8DITio604nNfuG9oY9QF+gFSEJTr1f4hLcow=; b=P2hwrjOfwGbOW/vFmpFinEKwCWDlW6Frj6UAnKHt39vJ5XT87hBZJyzns2l23xcDseO9T4 EWeCmgxeXdoTNFAQ== 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 7F546136E0 for ; Fri, 11 Oct 2024 14:35:42 +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 EG7SHb43CWfYFwAAD6G6ig (envelope-from ) for ; Fri, 11 Oct 2024 14:35:42 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH v2 5/5] [gdb] Handle bad alloc in cooked_index_worker::start Date: Fri, 11 Oct 2024 16:35:44 +0200 Message-Id: <20241011143544.15400-5-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20241011143544.15400-1-tdevries@suse.de> References: <20241011143544.15400-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,imap1.dmz-prg2.suse.org:helo]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_TLS_ALL(0.00)[] X-Spam-Level: X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.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~patchwork=sourceware.org@sourceware.org Say we simulate a bad alloc in post_task in cooked_index_worker::start: ... void cooked_index_worker::start () { + { + static bool throw_bad_alloc = true; + if (throw_bad_alloc) + { + throw_bad_alloc = false; + + va_list dummy; + throw gdb_quit_bad_alloc (gdb_exception_quit ("bad alloc", dummy)); + } + } gdb::thread_pool::g_thread_pool->post_task ([=] () ... That makes gdb hang: ... $ gdb -q -batch a.out bad alloc ... because we're waiting for the cooked index to transfer into cooked_state::CACHE_DONE. Fix that by catching the bad alloc in cooked_index_worker::start, and setting the cooked index to cooked_state::CACHE_DONE, as done in the posted task, getting us instead: ... $ gdb -q -batch a.out bad alloc $ ... Tested on aarch64-linux. --- gdb/dwarf2/cooked-index.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index 4073c924890..51e24b74239 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -465,20 +465,28 @@ cooked_index_shard::find (const std::string &name, bool completing) const void cooked_index_worker::start () { - gdb::thread_pool::g_thread_pool->post_task ([=] () - { - try - { - do_reading (); - } - catch (const gdb_exception &exc) + try + { + gdb::thread_pool::g_thread_pool->post_task ([=] () { - m_failed = exc; - set (cooked_state::CACHE_DONE); - } + try + { + do_reading (); + } + catch (const gdb_exception &exc) + { + m_failed = exc; + set (cooked_state::CACHE_DONE); + } - bfd_thread_cleanup (); - }); + bfd_thread_cleanup (); + }); + } + catch (const gdb_exception &exc) + { + m_failed = exc; + set (cooked_state::CACHE_DONE); + } } /* See cooked-index.h. */