From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrew Whatson Newsgroups: gmane.lisp.guile.devel Subject: [PATCH] Avoid 'frame-local-ref' errors when printing backtrace. Date: Tue, 20 Sep 2022 17:23:58 +1000 Message-ID: <20220920072358.4701-1-whatson@gmail.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37647"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Andrew Whatson To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Tue Sep 20 09:25:15 2022 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oaXd5-0009dZ-Ar for guile-devel@m.gmane-mx.org; Tue, 20 Sep 2022 09:25:15 +0200 Original-Received: from localhost ([::1]:48590 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oaXd4-0002T5-BM for guile-devel@m.gmane-mx.org; Tue, 20 Sep 2022 03:25:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57908) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaXc4-0002QQ-9r for guile-devel@gnu.org; Tue, 20 Sep 2022 03:24:14 -0400 Original-Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:40694) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaXc1-00075d-Sf for guile-devel@gnu.org; Tue, 20 Sep 2022 03:24:11 -0400 Original-Received: by mail-pf1-x434.google.com with SMTP id b75so1925327pfb.7 for ; Tue, 20 Sep 2022 00:24:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=PbPc5eteYjXkfp9rN6II7a+a2wig1wUO+/X6ZvdMpTI=; b=iwk1zn3/kbYpSuHaYpvRogNpptgU8T7dd2u/vJX9eGgA1XMikA6BcJfYKQPyrFl6i1 DAZIHciqK/1GLmoi2N3w3fBmv35efuklEwzzjBDg+1QriiTGFKw4d3RTc+Af8fYX+73N Jbijym+kR+ENIpPByg8RfbSDXTRVY4FFoaQrNjjgRlcFQq+C1NQcG2rLDib2KChQvXB7 w/YujkuF7F1yF28SM5zp4m9sZTld1rg+lw0JbXEO/HpWNWOHgAtaQIATyXiZ0OT2K35L 6Nswbg+M70gBpd1VWERy+iXOfvC9eDidKarwOR6k73kT2bO033jgCt9HVQkA7oDi2Wir zFyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=PbPc5eteYjXkfp9rN6II7a+a2wig1wUO+/X6ZvdMpTI=; b=z7AP2O6FL/fUWf97spVMKWFIYyJs4D8ib2Xdi6phtyKdhu9ZtZpo9LmP6zWyiK/NLh Uuoehg9PVFGdeFKjZw4MNAq99zBe+NIydfYXmo3k6B6y9qdikOYD4r9CkH6yWB33ARnj ZvuIOGesOv+FlQtyCzWJfocqXoaqyQ7UHm4mkD1kPHjBvxnC2F+52qBiwukzbiUs7nuY NkoiV5glU8vKkR4b5C3UHUlyDr7MIX0WxQDifRelHee5gNZ7Oze/8NTpSbUzgWytUEkA Nce9Z7JJjByw2i5sf6UWTG+KPEJjY1ktA9l5fnfbGIdRzWIZXkSwYGTi+lqpKNHCEG18 eedg== X-Gm-Message-State: ACrzQf3eEapq4pt1hU7AUFpgQsm/Bj0fWXQgQxvOrjO37nNrYPy3svHS lUAoqiFWnofrqg8uOt483vRX1YSCsl8= X-Google-Smtp-Source: AMsMyM59965xbgabG0LSzMGPXyHQKTKPya5RVPwiWai2WgREb7k7vvGFMwBFcqh0VBufWzWSxMX99g== X-Received: by 2002:a63:d511:0:b0:438:91d5:5a43 with SMTP id c17-20020a63d511000000b0043891d55a43mr18624210pgg.587.1663658647513; Tue, 20 Sep 2022 00:24:07 -0700 (PDT) Original-Received: from fumo.fritz.box (eft1854679.lnk.telstra.net. [101.187.131.186]) by smtp.gmail.com with ESMTPSA id x9-20020a1709027c0900b00176a579fae8sm660727pll.210.2022.09.20.00.24.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 00:24:07 -0700 (PDT) X-Mailer: git-send-email 2.37.3 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=whatson@gmail.com; helo=mail-pf1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.io gmane.lisp.guile.devel:21356 Archived-At: Workaround for . * module/system/vm/frame.scm (frame-call-representation): Treat a binding as "unspecified" if its slot exceeds 'frame-num-locals'. --- module/system/vm/frame.scm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/module/system/vm/frame.scm b/module/system/vm/frame.scm index 3be73e29c..6b14fc62a 100644 --- a/module/system/vm/frame.scm +++ b/module/system/vm/frame.scm @@ -381,8 +381,16 @@ (frame-local-ref frame i 'scm)) ((find-slot i bindings) => (lambda (binding) - (let ((val (frame-local-ref frame (binding-slot binding) - (binding-representation binding)))) + (let* ((slot (binding-slot binding)) + ;; HACK: Avoid out-of-range from frame-local-ref. + ;; Some frames have bindings beyond nlocals. That + ;; is probably a bug somewhere else, but at least + ;; this workaround allows them to be printed. + (val (if (< slot nlocals) + (frame-local-ref frame slot + (binding-representation binding)) + ;; else # + ))) ;; It could be that there's a value that isn't clobbered ;; by a call but that isn't live after a call either. In ;; that case, if GC runs during the call, the value will -- 2.37.3