[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Broken Backtraces, and Part of a Solution

From: Noah Lavine
Subject: Broken Backtraces, and Part of a Solution
Date: Wed, 18 Apr 2012 20:02:07 -0400

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

               (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.
                              ;; Narrow the end of the stack to the most recent
                              ;; start-stack.
                              ;; 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?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]