unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Andrew Whatson <whatson@gmail.com>
To: 57948@debbugs.gnu.org
Subject: bug#57948: Frame bindings referring to non-existent locals
Date: Tue, 20 Sep 2022 07:16:14 +0000	[thread overview]
Message-ID: <CAPE069dRtJvi4yMAm5ZauDmj7t40QnOxvkkRRB0yPZ+y893-0g@mail.gmail.com> (raw)

Hello Guilers!

I have some buggy code which fails to compile.  While printing the backtrace of
this compilation error, another error occurs and Guile reports "Exception thrown
while printing backtrace".

To reproduce the error:

  $ git clone https://gitlab.com/flatwhatson/guile-prescheme.git
  $ cd guile-prescheme
  $ git checkout d793730895aaeb4ee203f062ab3864af8fd1d5fd
  $ guild compile -L . ps-compiler/prescheme/flatten.scm

  <...snip...>
  In ice-9/eval.scm:
     626:19  7 (_ #<directory (ps-compiler prescheme linking) 7ff7692f…>)
     293:34  6 (_ #(#(#<directory (prescheme bcomp package) 7ff766…>) …))
     293:34  5 (_ #(#(#<directory (prescheme bcomp package) 7ff766…>) …))
     214:21  4 (_ #(#(#<directory (prescheme bcomp package) 7ff766…>) …))
     217:50  3 (lp (#<procedure 7ff7654c3f80 at ice-9/eval.scm:123:…> …))
     217:33  2 (lp (#<procedure 7ff7654c3f60 at ice-9/eval.scm:182:…> …))
  Exception thrown while printing backtrace:
  In procedure frame-local-ref: Argument 2 out of range: 1

  ice-9/boot-9.scm:1685:16: In procedure raise-exception:
  Wrong type to apply: #<srfi-69:hash-table real-table: #<hash-table 7faf5e6...
  <...snip...>

To investigate further, I've run the compile script from the repl and dug around
for the responsible frame:

  > ,use (scripts compile)
  > (compile "-L" "." "ps-compiler/prescheme/flatten.scm")
  ;; fails, enters debugger
  [1]> ,bt
  ;; fails to print backtrace
  [1]> ,m (system vm frame)
  [1]> ,use (system repl common) (system repl debug) (srfi srfi-43)
  [1]> (debug-frames (repl-debug (car (fluid-ref *repl-stack*))))
  ;; $1 is a vector of frame objects
  [1]> (define (dump-frame i f) (format #t "~a: ~a\n" i f) (frame-arguments f))
  [1]> (vector-for-each dump-frame $1)
  ;; fails on frame index 2
  [2]> (define (dump-binding b) (format #t "~a\n" b))
  [2]> (frame-num-locals (vector-ref $1 2))
  ;; problem frame has 1 local slot
  [2]> (for-each dump-binding (frame-bindings (vector-ref $1 2)))
  #<<binding> frame: #<frame 7fee83f4c440 lp> idx: 0 name: closure slot: 0 ...
  #<<binding> frame: #<frame 7fee83f4c440 lp> idx: 1 name: args slot: 1 ...
  [2]> (frame-num-locals (vector-ref $1 3))
  ;; parent frame has 2 local slots
  [2]> (for-each dump-binding (frame-bindings (vector-ref $1 3)))
  #<<binding> frame: #<frame 7fee83f4c430 lp> idx: 0 name: closure slot: 0 ...
  #<<binding> frame: #<frame 7fee83f4c430 lp> idx: 1 name: args slot: 1 ...

From this, it looks like there's a broken frame which has 2 bindings, but only 1
local slot, leading to the "out of range" error while printing the backtrace.
Curiously, its parent frame has the same 2 bindings, and 2 local slots as
expected.

Any ideas what is happening here?

Cheers,
Andrew





             reply	other threads:[~2022-09-20  7:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-20  7:16 Andrew Whatson [this message]
2022-09-20  9:29 ` bug#57948: Frame bindings referring to non-existent locals Andrew Whatson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPE069dRtJvi4yMAm5ZauDmj7t40QnOxvkkRRB0yPZ+y893-0g@mail.gmail.com \
    --to=whatson@gmail.com \
    --cc=57948@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).