unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#74422: Wrong expected column number while backtracing?
@ 2024-11-18 19:00 Olivier Dion
  0 siblings, 0 replies; only message in thread
From: Olivier Dion @ 2024-11-18 19:00 UTC (permalink / raw)
  To: 74422

Hi,

Sometime, the printed backtrace from Guile gives wrong column numbers.
This seems to happen when referencing free variables.

Here is a dummy example that represents the problem:
--8<---------------cut here---------------start------------->8---
;; test.scm
(use-modules
 (foo))

(define (main _)
  (foo))

;; foo.scm
(define-module (foo)
  #:use-module (system vm debug)
  #:use-module (system vm frame)
  #:use-module (system vm program)
  #:export (foo))

(define (bar)
  (lambda () (throw 'bar)))

(define (foo)
  (catch #t
    (bar)
    (const #f)
    (lambda _
      (let ((stack (make-stack #t)))
        (let lp ((frame (stack-ref stack 0)))
          (when frame
            (let ((source (frame-source frame)))
              (pk
               (and=> source source:file)
               (and=> source source:line-for-user)
               (and=> source source:column)))
            (lp (frame-previous frame))))))))
--8<---------------cut here---------------end--------------->8---

Then `guile -L . -e main -s test.scm:

;;; note: source file ./foo.scm
;;;       newer than compiled /home/old/.cache/guile/ccache/3.0-LE-8-4.6/home/old/foo.scm.go
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling ./foo.scm
;;; compiled /home/old/.cache/guile/ccache/3.0-LE-8-4.6/home/old/foo.scm.go

;;; (#f #f #f)

;;; ("foo.scm" 15 20)

;;; ("ice-9/boot-9.scm" 1780 13)

;;; ("ice-9/boot-9.scm" 1685 16)

;;; ("foo.scm" 8 13)

;;; ("ice-9/boot-9.scm" 1752 10)

;;; ("ice-9/boot-9.scm" 1747 15)

;;; ("ice-9/eval.scm" 619 8)

;;; ("ice-9/boot-9.scm" 724 2)

;;; (#f #f #f)

;;; ("ice-9/boot-9.scm" 1752 10)

See how the columns for foo.scm are weird:

foo.scm:15:20:
      (let ((stack (make-stack #t)))
                    ^

foo.scm:8:13:
  (lambda () (throw 'bar)))
             ^

When I would have expected the following:

foo.scm:15:20:
      (let ((stack (make-stack #t)))
                   ^

foo.scm:8:13:
  (lambda () (throw 'bar)))
        ^

Thanks,
Olivier
-- 
Olivier Dion
EfficiOS Inc.
https://www.efficios.com






^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-11-18 19:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-18 19:00 bug#74422: Wrong expected column number while backtracing? Olivier Dion

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