From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id KJoYEaBBZmR/VAAASxT56A (envelope-from ) for ; Thu, 18 May 2023 17:17:52 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id EBHxEKBBZmRLvwAA9RJhRA (envelope-from ) for ; Thu, 18 May 2023 17:17:52 +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 202882460C for ; Thu, 18 May 2023 17:17:52 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzfNf-0003e2-4b; Thu, 18 May 2023 11:17:28 -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 1pzfNH-0003Jw-9l for guix-patches@gnu.org; Thu, 18 May 2023 11:17:11 -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 1pzfNH-0001yC-1C for guix-patches@gnu.org; Thu, 18 May 2023 11:17:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pzfNG-0005Th-T8 for guix-patches@gnu.org; Thu, 18 May 2023 11:17:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63571] [PATCH 04/14] 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: Thu, 18 May 2023 15:17: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.168442301220980 (code B ref 63571); Thu, 18 May 2023 15:17:02 +0000 Received: (at 63571) by debbugs.gnu.org; 18 May 2023 15:16:52 +0000 Received: from localhost ([127.0.0.1]:54118 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pzfN6-0005SE-7w for submit@debbugs.gnu.org; Thu, 18 May 2023 11:16:52 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36056) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pzfMv-0005QN-ME for 63571@debbugs.gnu.org; Thu, 18 May 2023 11:16:44 -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 1pzfMq-0001ui-Fp; Thu, 18 May 2023 11:16:36 -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=B+WSVuUnLO9fq/O0PJlW oglMxj9NKLy1VEYCyJJwRo9UBf1DZT7ABAWfblctwZNWZs/WQsowEODfY8scVCx92TO0OV+v+u6It RHuOQ4E6u/Lf2BQJGLU647PnV4drznZivdgvCfbQb+bTxzBH/YTEgJiFVTw/wAMdfHLnYku73/sUw FdgALwVmqTMc/XEPScanBGq/nfhkLuHU6y026vMDGytMdy/5VCR2Dd8fr8hiJIkZ4POWROTBDFzur Qxm0PDEDwn6LuI9wKCE/5WDDFBr2liEI2jbv05MkI8ku+OBJ2RNvTiNxqofOBccBnF43PtadXFVOs hdX8AugCeT38dg==; 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 1pzfMq-0007G6-2j; Thu, 18 May 2023 11:16:36 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Thu, 18 May 2023 17:16:12 +0200 Message-Id: <507259949ceaf08af93f2d4e17e61797f86989b2.1684421460.git.ludo@gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: 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=1684423072; a=rsa-sha256; cv=none; b=LL0MopcVS2kBAtz9nWdkDsAdgOy+7ENIAk1CIK0IEKBQvNfe+iLxykYa3vPA0WsVZa6Ms7 01R/7Q91hjrHLFWvNq0a0/BbiB6FXCoarMEk9F4gIjJIl21X5/643F+A9DS61QXnpaHEkg YifWaBXEIAKIl1oSsOl6j6a4XjTZG7pYl9F5hbh3oY9A+EwJo/ROuJbdYzFWclh5RNBFbt o9ztjyHSS8vpMAyklHITml9OD1eh+i4CCDzgxZRsj90UNbgh7hoAS4hxrviCx5XJJLH87q pV87EjSsQE+5jNeUZ4fPveXAlUqaJOjW+ZFjR06+eKDCTlORDisDpGc142RGFg== 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=B+WSVuUn; 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=1684423072; 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=KdbdPvw7I1bZMqLcbwUOneqqYJv/6rGRChbm2veImkWwc2YKA4oiA/DTgWEe9/+joJ5LR6 tAThJAvvcErR7OkpvjJeg0s0b1+UK2VBZN176YnuBYlMFnUN5/FfA6UPw71H4xtp6Zo720 xO3X16ADi5BIuBWHqqQZRDZW3MuGSE0AtW1mhx/nnWU6S7QEVRbVy9in4N2WXmDpxNV+Vl Y7VHvDnd3teCgnz6n6Ct0WrxEd+IljX7llntpW/ktzStZVmW9pwFv/BwjuoWfq2SF4PsLu qlMjkQ8+kNyRe7p9jFbRqXbBRX19ucpPujHceYHnqxuSu3hpqs/PQeasIKvaWQ== X-Migadu-Spam-Score: -2.41 X-Spam-Score: -2.41 X-Migadu-Queue-Id: 202882460C 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=B+WSVuUn; 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: LNEeN0uvC7b8 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