GNU bug report logs - #57948
Frame bindings referring to non-existent locals

Previous Next

Package: guile;

Reported by: Andrew Whatson <whatson <at> gmail.com>

Date: Tue, 20 Sep 2022 07:17:01 UTC

Severity: normal

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 57948 in the body.
You can then email your comments to 57948 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#57948; Package guile. (Tue, 20 Sep 2022 07:17:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Andrew Whatson <whatson <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Tue, 20 Sep 2022 07:17:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Andrew Whatson <whatson <at> gmail.com>
To: bug-guile <at> gnu.org
Subject: Frame bindings referring to non-existent locals
Date: Tue, 20 Sep 2022 07:16:14 +0000
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




Information forwarded to bug-guile <at> gnu.org:
bug#57948; Package guile. (Tue, 20 Sep 2022 09:30:01 GMT) Full text and rfc822 format available.

Message #8 received at 57948 <at> debbugs.gnu.org (full text, mbox):

From: Andrew Whatson <whatson <at> gmail.com>
To: 57948 <at> debbugs.gnu.org
Subject: Re: bug#57948: Frame bindings referring to non-existent locals
Date: Tue, 20 Sep 2022 09:29:23 +0000
I've submitted a workaround for this problem here:
https://lists.gnu.org/archive/html/guile-devel/2022-09/msg00016.html




Information forwarded to bug-guile <at> gnu.org:
bug#57948; Package guile. (Wed, 12 Oct 2022 20:35:02 GMT) Full text and rfc822 format available.

Message #11 received at 57948 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Andrew Whatson <whatson <at> gmail.com>
Cc: 57948 <at> debbugs.gnu.org, guile-devel <at> gnu.org
Subject: Re: [PATCH] Avoid 'frame-local-ref' errors when printing backtrace.
Date: Wed, 12 Oct 2022 22:34:24 +0200
Hi Andrew,

Andrew Whatson <whatson <at> gmail.com> skribis:

> 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'.

Yay, great to see that fixed (or almost)!

It would be great if you could add a simple test case though, so that
the bug doesn’t eventually come back to haunt us.

Could you send an updated patch?

Thanks,
Ludo’.

PS: BTW, it’ll be great to have more patches from you!  :-) To that end,
    please check out the new Guile copyright policy and let us know what
    option you’d like to choose:
    <https://lists.gnu.org/archive/html/guile-devel/2022-10/msg00008.html>.




Information forwarded to bug-guile <at> gnu.org:
bug#57948; Package guile. (Thu, 13 Oct 2022 03:37:01 GMT) Full text and rfc822 format available.

Message #14 received at 57948 <at> debbugs.gnu.org (full text, mbox):

From: Andrew Whatson <whatson <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 57948 <at> debbugs.gnu.org, guile-devel <at> gnu.org
Subject: Re: [PATCH] Avoid 'frame-local-ref' errors when printing backtrace.
Date: Thu, 13 Oct 2022 13:36:20 +1000
Ludovic Courtès <ludo <at> gnu.org> wrote:
>
> It would be great if you could add a simple test case though, so that
> the bug doesn’t eventually come back to haunt us.
>
> Could you send an updated patch?

Ah yes, getting this covered in a test is on my list.  I had trouble
writing a reproducer previously, I think the bug might only occur in a
nested compilation context (top-level error compiling a dependency
module), but I'll have another go.

> PS: BTW, it’ll be great to have more patches from you!  :-) To that end,
>     please check out the new Guile copyright policy and let us know what
>     option you’d like to choose:
>     <https://lists.gnu.org/archive/html/guile-devel/2022-10/msg00008.html>.

I have already assigned copyright of my work on Guile to the FSF,
happy for that to remain.

That said, I'm glad to see this requirement being eased!

Cheers,
Andrew




Information forwarded to bug-guile <at> gnu.org:
bug#57948; Package guile. (Thu, 13 Oct 2022 13:10:01 GMT) Full text and rfc822 format available.

Message #17 received at 57948 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Andrew Whatson <whatson <at> gmail.com>
Cc: 57948 <at> debbugs.gnu.org, guile-devel <at> gnu.org
Subject: Re: [PATCH] Avoid 'frame-local-ref' errors when printing backtrace.
Date: Thu, 13 Oct 2022 15:09:16 +0200
Hi,

Andrew Whatson <whatson <at> gmail.com> skribis:

> Ludovic Courtès <ludo <at> gnu.org> wrote:
>>
>> It would be great if you could add a simple test case though, so that
>> the bug doesn’t eventually come back to haunt us.
>>
>> Could you send an updated patch?
>
> Ah yes, getting this covered in a test is on my list.  I had trouble
> writing a reproducer previously, I think the bug might only occur in a
> nested compilation context (top-level error compiling a dependency
> module), but I'll have another go.

Awesome.

>> PS: BTW, it’ll be great to have more patches from you!  :-) To that end,
>>     please check out the new Guile copyright policy and let us know what
>>     option you’d like to choose:
>>     <https://lists.gnu.org/archive/html/guile-devel/2022-10/msg00008.html>.
>
> I have already assigned copyright of my work on Guile to the FSF,
> happy for that to remain.

Oh sorry I had overlooked that, perfect!

Thanks,
Ludo’.




Information forwarded to bug-guile <at> gnu.org:
bug#57948; Package guile. (Wed, 11 Jan 2023 05:25:01 GMT) Full text and rfc822 format available.

Message #20 received at 57948 <at> debbugs.gnu.org (full text, mbox):

From: Andrew Whatson <whatson <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 57948 <at> debbugs.gnu.org, guile-devel <at> gnu.org
Subject: Re: [PATCH] Avoid 'frame-local-ref' errors when printing backtrace.
Date: Wed, 11 Jan 2023 15:24:15 +1000
[Message part 1 (text/plain, inline)]
Ludovic Courtès <ludo <at> gnu.org> wrote:
>
> It would be great if you could add a simple test case though, so that
> the bug doesn’t eventually come back to haunt us.

I've finally tracked this one down, a patch with a unit test for this
bug is attached.

Cheers,
Andrew
[test-frame-local-ref-error.patch (text/x-patch, attachment)]

Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Wed, 11 Jan 2023 23:04:01 GMT) Full text and rfc822 format available.

Notification sent to Andrew Whatson <whatson <at> gmail.com>:
bug acknowledged by developer. (Wed, 11 Jan 2023 23:04:01 GMT) Full text and rfc822 format available.

Message #25 received at 57948-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Andrew Whatson <whatson <at> gmail.com>
Cc: lloda <lloda <at> sarc.name>, 57948-done <at> debbugs.gnu.org, guile-devel <at> gnu.org
Subject: Re: [PATCH] Avoid 'frame-local-ref' errors when printing backtrace.
Date: Thu, 12 Jan 2023 00:03:22 +0100
Hi,

Andrew Whatson <whatson <at> gmail.com> skribis:

> commit 164bdce6acf53796cb96ef1930a89c6caf84bc39
> Author: Andrew Whatson <whatson <at> gmail.com>
> Date:   Wed Jan 11 14:04:32 2023 +1000
>
>     Test for 'frame-local-ref' errors when printing backtrace.
>     
>     This test reproduces the error from <https://bugs.gnu.org/56493>, and
>     passes with the workaround which was merged in commit
>     c7fa78fc751eb336bcfafbb5ac59c460ee2c5d7a.
>     
>     * test-suite/tests/eval.test ("avoid frame-local-ref out of range"): New
>     test.

Applied, thanks!

Ludo’.

PS: Please use ‘git format-patch’ so the patch can be directly consumed
    by ‘git am’.




Information forwarded to bug-guile <at> gnu.org:
bug#57948; Package guile. (Thu, 12 Jan 2023 02:10:02 GMT) Full text and rfc822 format available.

Message #28 received at 57948-done <at> debbugs.gnu.org (full text, mbox):

From: Andrew Whatson <whatson <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: lloda <lloda <at> sarc.name>, 57948-done <at> debbugs.gnu.org, guile-devel <at> gnu.org
Subject: Re: [PATCH] Avoid 'frame-local-ref' errors when printing backtrace.
Date: Thu, 12 Jan 2023 12:09:18 +1000
Ludovic Courtès <ludo <at> gnu.org> wrote:
>
> Applied, thanks!

Thank you!

> PS: Please use ‘git format-patch’ so the patch can be directly consumed
>     by ‘git am’.

My mistake, sorry about that.  Noted for next time :)

Cheers,
Andrew




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 09 Feb 2023 12:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 77 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.