From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id mIECFgC7dGR/HAAASxT56A (envelope-from ) for ; Mon, 29 May 2023 16:47:28 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id kOU3FgC7dGSo6QAA9RJhRA (envelope-from ) for ; Mon, 29 May 2023 16:47:28 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 2C15430E27 for ; Mon, 29 May 2023 16:47:28 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3e9J-00022X-RV; Mon, 29 May 2023 10:47:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3e9G-000220-Nm for guix-patches@gnu.org; Mon, 29 May 2023 10:47:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q3e9G-00032v-D9 for guix-patches@gnu.org; Mon, 29 May 2023 10:47:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q3e9G-0001Oe-9F for guix-patches@gnu.org; Mon, 29 May 2023 10:47:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63571] [PATCH v2 04/19] import: utils: 'call-with-networking-exception-handler' doesn't unwind. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 29 May 2023 14:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63571 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63571@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 63571-submit@debbugs.gnu.org id=B63571.16853715655182 (code B ref 63571); Mon, 29 May 2023 14:47:02 +0000 Received: (at 63571) by debbugs.gnu.org; 29 May 2023 14:46:05 +0000 Received: from localhost ([127.0.0.1]:58767 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q3e8K-0001LI-JJ for submit@debbugs.gnu.org; Mon, 29 May 2023 10:46:05 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45828) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q3e87-0001IC-BK for 63571@debbugs.gnu.org; Mon, 29 May 2023 10:45:51 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3e81-0002dz-Tu; Mon, 29 May 2023 10:45:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=fxmA7SgFcntyA5wRPbxN7LoFNiFasucsGTERoU5qcPE=; b=BTCxgxeIYCczkOha6/oW s/yMPK/Jl7xHCzOzdcOunV4WgnCnVTU3YxpCkhOTu59dsCayQk5drSu+fsVDaz7jEnAyAph/uieK7 nPt8Gq56ni/vEHC5hM5iiHDgHHupzTxGU7uzg/rv9b6NfzP21s0POoTFNtdiE4vS8jdzMrJyeGaEc GxyB1zDXVWiuSJcfGaGEbN0RpPXulOv1lnoarS5AnG3CWl/pTrqXzjPdW/pUPnxBZHGVAcNdUZIQj FXMT68YJGgakuQCNfwur7sNjiHYJ2rGfv8FNpOJVOCnNR//fH715KZ1PmAm0jHR+QEis5uqpf5R+X O3R2a4hQdFXvzA==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3e80-00044B-1B; Mon, 29 May 2023 10:45:45 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Mon, 29 May 2023 16:45:15 +0200 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: <87y1l7fb9j.fsf@gnu.org> References: <87y1l7fb9j.fsf@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1685371648; a=rsa-sha256; cv=none; b=Yi4eT1OqK/mMpbsFyd81AX33wwXI0lZQ4e4WcPJOTGpyyL1EgWJ1ASkUHBFyOW5kT9tXld e/wR6TdmX8r9+ltSVLXKQo6KQYJ7T+alnCyRVu9DtL1N9iClPM/VK7HpsshOWCb9m6Egby SDfTx44HurjebO0M12uIhLR8rrK1dlPGwzqPDxGU4p8u3eITpPWKOOd9I7ajqWbJpuTkA1 yItYCFXOaO+MGlgvzkMI3259ykmJj+CzRoF1ZPJ3luhH6ZsGABxJO4KlGXLPmlC4Cpo/0q 3AiN6qOScQoSWPEIQsWAmYZgpH9M16kWAC+wUpcT7UxpKTE/TLsrX09iFTzimQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=BTCxgxeI; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1685371648; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=fxmA7SgFcntyA5wRPbxN7LoFNiFasucsGTERoU5qcPE=; b=f0NRgwmQH2Y/OpyWD410nVTSJOywQrfZKFZeicYu1k6KpGae6GvevvNSv5VEGUWPSvT0rI jMgtRiF6Ev1Rx7azJ65IN27sSBq+eYpTFjmSCWgbDsyfUMfq5hOO2QyGtBkBWn02rW2/dH dTl5e6KDSv7WvmgtdriXSaVi9D8LRJUM8BPEJhbONKNvIEWzK8Wzwh5N8P+Afp578AhT/q d5d5Y13gtaVXVs8FPSfDIk6tULSGLwF+jSxB/RlaxJoKRHcbHYcLFYWbEdsl+5qsX95xnu tN5nAm1mOObSKsj30KlyWpLm/n4lvrBrGE7bjtafuA+z33iTCSe4bBkw8ZIhAQ== X-Migadu-Spam-Score: -2.11 X-Spam-Score: -2.11 X-Migadu-Queue-Id: 2C15430E27 X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=BTCxgxeI; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-TUID: nu90/jTRnHql That way backtraces show where the error actually originates from. * guix/import/utils.scm (call-with-networking-exception-handler): Rewrite using 'with-exception-handler'. --- guix/import/utils.scm | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/guix/import/utils.scm b/guix/import/utils.scm index 177817b10c..e9a0a7ecd7 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -45,6 +45,7 @@ (define-module (guix import utils) #:use-module (guix sets) #:use-module ((guix ui) #:select (fill-paragraph)) #:use-module (gnu packages) + #:autoload (ice-9 control) (let/ec) #:use-module (ice-9 match) #:use-module (ice-9 rdelim) #:use-module (ice-9 receive) @@ -126,18 +127,26 @@ (define (flatten lst) (define (call-with-networking-exception-handler thunk) "Invoke THUNK, returning #f if one of the usual networking exception is thrown." - (catch #t - (lambda () - (guard (c ((http-get-error? c) #f)) - (thunk))) - (lambda (key . args) - ;; Return false and move on upon connection failures and bogus HTTP - ;; servers. - (unless (memq key '(gnutls-error tls-certificate-error - system-error getaddrinfo-error - bad-header bad-header-component)) - (apply throw key args)) - #f))) + (let/ec return + (with-exception-handler + (lambda (exception) + (cond ((http-get-error? exception) + (return #f)) + (((exception-predicate &exception-with-kind-and-args) exception) + ;; Return false and move on upon connection failures and bogus + ;; HTTP servers. + (if (memq (exception-kind exception) + '(gnutls-error tls-certificate-error + system-error getaddrinfo-error + bad-header bad-header-component)) + (return #f) + (raise-exception exception))) + (else + (raise-exception exception)))) + thunk + + ;; Do not unwind to preserve meaningful backtraces. + #:unwind? #f))) (define-syntax-rule (false-if-networking-error exp) "Evaluate EXP, returning #f if a networking-related exception is thrown." -- 2.40.1