unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Noah Lavine <noah.b.lavine@gmail.com>
To: guile-devel <guile-devel@gnu.org>
Subject: Broken Backtraces, and Part of a Solution
Date: Wed, 18 Apr 2012 20:02:07 -0400	[thread overview]
Message-ID: <CA+U71=P+bACXoiChxNoP0W4HUnu2VJBy+kd-P3PdeQEjyewe6g@mail.gmail.com> (raw)

Hello all,

I recently realized that backtraces weren't working for me in the most
recent build of Guile master. Specifically, I could get to a debug
prompt fine, but when I tried to get a backtrace, it always came up
empty. The problem happens in this code in
module/system/repl/error-handling.scm:

               (let* ((tag (and (pair? (fluid-ref %stacks))
                                (cdar (fluid-ref %stacks))))
                      (stack (narrow-stack->vector
                              (make-stack #t)
                              ;; Cut three frames from the top of the stack:
                              ;; make-stack, this one, and the throw handler.
                              3
                              ;; Narrow the end of the stack to the most recent
                              ;; start-stack.
                              tag
                              ;; And one more frame, because
%start-stack invoking
                              ;; the start-stack thunk has its own frame too.
                              0 (and tag 1)))
                      (error-msg (error-string stack key args))
                      (debug (make-debug stack 0 error-msg #f)))

(note: there are two instances of almost exactly the same code. the
problem I see happens at the second instance, but the first would
probably be the same)

The problem is that narrow-stack->vector returns #(). It does this
because the stack is narrowed to nothing. The narrowing really happens
in the functions scm_make_stack and narrow_stack, in stacks.c.

The reason it narrows to nothing is the third argument to
narrow-stack->vector, tag. On my Guile build, tag evaluates to
'("start-stack"). The code is trying to use the tag to trim extra
frames off of the stack, but we can only trim with procedures,
symbols, and integers. The fallback behavior is to eliminate the
entire stack, which is what we see here.

It's possible to solve this problem by using %start-stack instead of
'("start-stack"), but that doesn't seem to be as general as the
solution in this function. Instead, here's a question - why are we
using (cdar (fluid-ref %stacks)) to get the stack tag, and what was
someone expecting that to return when they wrote it?

Thanks,
Noah



             reply	other threads:[~2012-04-19  0:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-19  0:02 Noah Lavine [this message]
2012-04-19  0:13 ` Broken Backtraces, and Part of a Solution Noah Lavine
2012-04-19  0:56 ` Andy Wingo
2012-04-19  1:08   ` Noah Lavine
2012-04-19  1:36     ` Andy Wingo
2012-04-19  2:13       ` Noah Lavine
2012-04-20  2:47         ` Noah Lavine
2012-04-20 14:13           ` Andy Wingo
2012-04-22 10:53           ` Ludovic Courtès
2012-04-24  1:42             ` Noah Lavine
2012-04-24 16:58               ` Ludovic Courtès

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='CA+U71=P+bACXoiChxNoP0W4HUnu2VJBy+kd-P3PdeQEjyewe6g@mail.gmail.com' \
    --to=noah.b.lavine@gmail.com \
    --cc=guile-devel@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).