From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 611863857C5F for ; Fri, 11 Oct 2024 14:35:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 611863857C5F 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 611863857C5F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728657346; cv=none; b=auS1xcp3VwLgLLJm7g8Wl0Vyf4Dsk9K4fFElRWKjftgLU5TO8SH63/oq4/GUlD4U82bsbGDzpEedQoUW1z/hR+kswsCrR/4GJ3n8sCW3aKjE6JLl5ImWKOeTqTO+fbJOkvuJwAjE/eT1I7NWD2G00izAqq2+pngzpnpQJCj99vA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728657346; c=relaxed/simple; bh=y/7Tkq0oaVfo5p5APfqS4aq6FbsNAFHqBGTyLO8hJ4U=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=khm7dDVo5W/+C42mNlr4hKVK3Dl7oiTylrHgWJETDNm0gKFuaT4lDdl839iN+fLFYo6ukJXZ4ZfV5C/n/TnzMWQ2yBdufgUWYNgYtYDyej4+z8JUbeqvM5XYq8BUqflSh+DfZy4PViqWKIGe73H2ECI76rSZwnkrWfaNH/djwR8= 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 5E6471FF09 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=PyIOADEJVE4smIib5GfdbTAvrJjB5uNDHLmsDqrjZ+Y=; b=uo7+53TmL0AOd6dZ1PYPnTqMHyKzfcxI5HMg35gb0knYuT35f2owFlJOsUzZhBfJ1RsTk/ +mAr+NmO2ua8c0LW8ILjoWs7IpRd9uucy9HF+dCz0ziXpn5HhTLkX9PKkwnaYZ39zbcmhG m2GzHeLAu2w2EMe0asbSVMjRqwHmNL8= 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=PyIOADEJVE4smIib5GfdbTAvrJjB5uNDHLmsDqrjZ+Y=; b=UEv2mYRDGIS3EFMna03lorBAf/9111GYsI+Muft4w1MhP1hr3VrMetclg1Vurx/I1/xq0r ORwDUWKxohIg7NCA== 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=PyIOADEJVE4smIib5GfdbTAvrJjB5uNDHLmsDqrjZ+Y=; b=uo7+53TmL0AOd6dZ1PYPnTqMHyKzfcxI5HMg35gb0knYuT35f2owFlJOsUzZhBfJ1RsTk/ +mAr+NmO2ua8c0LW8ILjoWs7IpRd9uucy9HF+dCz0ziXpn5HhTLkX9PKkwnaYZ39zbcmhG m2GzHeLAu2w2EMe0asbSVMjRqwHmNL8= 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=PyIOADEJVE4smIib5GfdbTAvrJjB5uNDHLmsDqrjZ+Y=; b=UEv2mYRDGIS3EFMna03lorBAf/9111GYsI+Muft4w1MhP1hr3VrMetclg1Vurx/I1/xq0r ORwDUWKxohIg7NCA== 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 45A65136E0 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 UJK9D743CWfYFwAAD6G6ig (envelope-from ) for ; Fri, 11 Oct 2024 14:35:42 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH v2 3/5] [gdb] Handle bad alloc in cooked_index_debug_info::do_reading Date: Fri, 11 Oct 2024 16:35:42 +0200 Message-Id: <20241011143544.15400-3-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 Content-Transfer-Encoding: 8bit X-Spam-Level: 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-Score: -2.80 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 List-Id: Say we simulate done_reading throwing a bad alloc in cooked_index_debug_info::do_reading: ... gdb::task_group workers ([this] () { + { + 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)); + } + } this->done_reading (); }); ... This gets gdb to terminate: ... $ gdb -q -batch -ex "file a.out" terminate called after throwing an instance of 'gdb_quit_bad_alloc' ... because the gdb::task_group finalizer is called from the destructor gdb::~task_group. Fix this by catching the exception and storing it in m_failed, as done in cooked_index_worker::start, such that we get: ... $ gdb -q -batch -ex "file a.out" bad alloc $ ... Tested on aarch64-linux. --- gdb/dwarf2/read.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index ea31d8dd851..771be5bfdfe 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -5012,7 +5012,15 @@ cooked_index_debug_info::do_reading () /* Work is done in a task group. */ gdb::task_group workers ([this] () { - this->done_reading (); + try + { + this->done_reading (); + } + catch (gdb_exception &exc) + { + this->m_failed = std::move (exc); + this->set (cooked_state::CACHE_DONE); + } }); auto end = per_bfd->all_units.end (); -- 2.35.3