unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [PATCH] Avoid 'frame-local-ref' errors when printing backtrace.
@ 2022-09-20  7:23 Andrew Whatson
  2022-09-21 10:50 ` Maxime Devos
  0 siblings, 1 reply; 12+ messages in thread
From: Andrew Whatson @ 2022-09-20  7:23 UTC (permalink / raw)
  To: guile-devel; +Cc: Andrew Whatson

Workaround for <https://bugs.gnu.org/57948>.

* 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 #<unspecified>
+                             )))
                ;; 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




^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-01-12  2:09 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-20  7:23 [PATCH] Avoid 'frame-local-ref' errors when printing backtrace Andrew Whatson
2022-09-21 10:50 ` Maxime Devos
2022-09-22 13:53   ` Andrew Whatson
2022-09-22 15:10     ` Maxime Devos
2022-10-12 20:34     ` Ludovic Courtès
2022-10-13  3:36       ` Andrew Whatson
2022-10-13 13:09         ` Ludovic Courtès
2023-01-11  5:24       ` Andrew Whatson
2023-01-11 23:03         ` Ludovic Courtès
2023-01-12  2:09           ` Andrew Whatson
2022-11-29 18:06     ` lloda
2022-09-22 13:58   ` Andrew Whatson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).