unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Broken Backtraces, and Part of a Solution
@ 2012-04-19  0:02 Noah Lavine
  2012-04-19  0:13 ` Noah Lavine
  2012-04-19  0:56 ` Andy Wingo
  0 siblings, 2 replies; 11+ messages in thread
From: Noah Lavine @ 2012-04-19  0:02 UTC (permalink / raw)
  To: guile-devel

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



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

end of thread, other threads:[~2012-04-24 16:58 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-19  0:02 Broken Backtraces, and Part of a Solution Noah Lavine
2012-04-19  0:13 ` 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

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