From patchwork Mon May 29 14:45:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 50426 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id D9BB027BBEA; Mon, 29 May 2023 15:47:28 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 30C8327BBE9 for ; Mon, 29 May 2023 15:47:28 +0100 (BST) 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 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches 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."