From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Noah Lavine Newsgroups: gmane.lisp.guile.devel Subject: Re: Broken Backtraces, and Part of a Solution Date: Wed, 18 Apr 2012 20:13:53 -0400 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1334794442 23865 80.91.229.3 (19 Apr 2012 00:14:02 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 19 Apr 2012 00:14:02 +0000 (UTC) To: guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Apr 19 02:14:01 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SKf0b-0000KJ-6b for guile-devel@m.gmane.org; Thu, 19 Apr 2012 02:14:01 +0200 Original-Received: from localhost ([::1]:47043 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKf0a-0005i5-FM for guile-devel@m.gmane.org; Wed, 18 Apr 2012 20:14:00 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:49644) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKf0Y-0005hx-02 for guile-devel@gnu.org; Wed, 18 Apr 2012 20:13:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SKf0V-0003rW-Sd for guile-devel@gnu.org; Wed, 18 Apr 2012 20:13:57 -0400 Original-Received: from mail-iy0-f169.google.com ([209.85.210.169]:60254) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKf0V-0003rG-Jn for guile-devel@gnu.org; Wed, 18 Apr 2012 20:13:55 -0400 Original-Received: by iajr24 with SMTP id r24so13874332iaj.0 for ; Wed, 18 Apr 2012 17:13:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; bh=v5p7EnCMY7sq73nrLTP6O0JoZ+SXUIIESXGUoNxJ2Ec=; b=okLnUJRK8evnH+Lhoal5xRNkB2HLiy8MyKRWCDE7/2kyj7J212gtM/Sbxh7jk83Da9 gtfXyLy2pVc7zyQ4W1gj4khovFvqlRV1wxg6t9nr2X+xrnLaVg33deepH1fAxjQGeR+o lIbnqO2gawqgO244+u9hRWT3VW/pO7G/GTTiBBDzF6NR7PF7MBJP3kFuTTayx/2T8hk8 PQzfwkuIiO5DIcEoRYc5ogDMmgxolrZRielNQR+Qot507ExbrxG6hBaYA9dlSxXnwz6Z pSGjazLpgC4NME+bBHHCTthoyXAqZ0hOG32Xf4+r1KMxV9Q9eXtgXdLIcTB7Rw/cwVk8 wPUg== Original-Received: by 10.42.169.132 with SMTP id b4mr29951icz.5.1334794433780; Wed, 18 Apr 2012 17:13:53 -0700 (PDT) Original-Received: by 10.42.29.200 with HTTP; Wed, 18 Apr 2012 17:13:53 -0700 (PDT) In-Reply-To: X-Google-Sender-Auth: -1p1Sbe-RsaYKQzE1U6CwysoFFw X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.210.169 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:14282 Archived-At: Sorry for the quick update, but this seems to be a result of commit 283ab48d3f20a5c5281cafc29f0c30c8d8ace9ee, on March 7th. The fluid %stacks is set in %start-stack, in boot-9.scm. %start-stack calls make-prompt-tag, also in boot-9.scm. The commit above switched prompt tags from using gensyms to using lists. This is much faster, but it also made backtraces break, because narrow_stack has the ability to search for symbols but not for lists. The fix I'd like to implement is to change the make-stack interface. It trims stacks according to its arguments, but it tries to be too clever - if it's passed an integer, it trims that many frames. If it's passed a procedure, it trims that many procedures. If it's passed a symbol, it trims until it sees the corresponding prompt. That worked fine as long as prompt tags are always symbols, but breaks when they are not. We could fix it quickly by letting make-stack trim on pairs the same as symbols, but that seems likely to break again. Instead, what if the user could specify the sort of trimming they wanted? Something like this: (make-stack #t '(inner prompt-tag ("start-stack"))) would trim the stack from the innermost frame looking for prompt tag '("start-stack"). (make-stack #t (outer frames 3)) would trim the outermost 3 frames from the stack. The make-stack interface isn't used very much, according to grep, so it wouldn't be hard to change all of its uses over to the new one. Noah On Wed, Apr 18, 2012 at 8:02 PM, Noah Lavine wrot= e: > 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: > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 (let* ((tag (and (pair? (fluid-ref %stacks)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(cdar (flu= id-ref %stacks)))) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(stack (narrow-stack->vector > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(make-stack #t= ) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; Cut three f= rames from the top of the stack: > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; make-stack,= this one, and the throw handler. > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A03 > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; Narrow the = end of the stack to the most recent > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; start-stack= . > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0tag > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; And one mor= e frame, because > %start-stack invoking > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; the start-s= tack thunk has its own frame too. > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A00 (and tag 1))= ) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(error-msg (error-string stack= key args)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(debug (make-debug stack 0 err= or-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