unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Where is the backtrace?
@ 2014-01-03  2:30 Panicz Maciej Godek
  2014-01-03 10:28 ` Ian Price
  0 siblings, 1 reply; 5+ messages in thread
From: Panicz Maciej Godek @ 2014-01-03  2:30 UTC (permalink / raw)
  To: guile-user@gnu.org

> (define (f) (define (g) (define (h) ((lambda x (cdr x)))) (h)) (g))
> (f)
<unnamed port>:13:0: In procedure #<procedure 24df3a0 at <current
input>:13:0 x>:
<unnamed port>:13:0: In procedure cdr: Wrong type argument in position
1 (expecting pair): ()

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue

> ,bt
In current input:
     13:0  0 (#<procedure 24df3a0 at <current input>:13:0 x>)

Why isn't the information about the subsequent procedures tracked? Do
they all get inlined?

regards,
M.



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

* Re: Where is the backtrace?
  2014-01-03  2:30 Where is the backtrace? Panicz Maciej Godek
@ 2014-01-03 10:28 ` Ian Price
  2014-01-03 13:57   ` Panicz Maciej Godek
  0 siblings, 1 reply; 5+ messages in thread
From: Ian Price @ 2014-01-03 10:28 UTC (permalink / raw)
  To: Panicz Maciej Godek; +Cc: guile-user@gnu.org

Panicz Maciej Godek <godek.maciek@gmail.com> writes:

>> (define (f) (define (g) (define (h) ((lambda x (cdr x)))) (h)) (g))
>> (f)
> <unnamed port>:13:0: In procedure #<procedure 24df3a0 at <current
> input>:13:0 x>:
> <unnamed port>:13:0: In procedure cdr: Wrong type argument in position
> 1 (expecting pair): ()
>
> Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue
>
>> ,bt
> In current input:
>      13:0  0 (#<procedure 24df3a0 at <current input>:13:0 x>)
>
> Why isn't the information about the subsequent procedures tracked? Do
> they all get inlined?

scheme@(guile-user)> ,optimize (define (f) (define (g) (define (h) ((lambda x (cdr x)))) (h)) (g))
$2 = (define (f) (cdr '()))

So, yes.

Though not relevant to this case, there is also another important factor
in your code, which is that all function calls are tail calls. So even
if you turned off optimisation, you would not see a complete backtrace.

-- 
Ian Price -- shift-reset.com

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"



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

* Re: Where is the backtrace?
  2014-01-03 10:28 ` Ian Price
@ 2014-01-03 13:57   ` Panicz Maciej Godek
  2014-01-03 16:15     ` Ian Price
  2014-01-03 18:03     ` Mark H Weaver
  0 siblings, 2 replies; 5+ messages in thread
From: Panicz Maciej Godek @ 2014-01-03 13:57 UTC (permalink / raw)
  To: Panicz Maciej Godek, guile-user@gnu.org

2014/1/3 Ian Price <ianprice90@googlemail.com>:
[...]
>> Why isn't the information about the subsequent procedures tracked? Do
>> they all get inlined?
>
> scheme@(guile-user)> ,optimize (define (f) (define (g) (define (h) ((lambda x (cdr x)))) (h)) (g))
> $2 = (define (f) (cdr '()))
>
> So, yes.
>
> Though not relevant to this case, there is also another important factor
> in your code, which is that all function calls are tail calls. So even
> if you turned off optimisation, you would not see a complete backtrace.

I've checked this with other implementations. Racket, Gambit and Biwa
Scheme were equally uninformative. Kawa's backtrace was a nightmare to
me, but perhaps someone with more knowledge would be able to infer the
actual location of the error. Actually, the only implementation that
exposed the exact location was Chicken. It proves that there must be a
way to track this information in spite of TCO.



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

* Re: Where is the backtrace?
  2014-01-03 13:57   ` Panicz Maciej Godek
@ 2014-01-03 16:15     ` Ian Price
  2014-01-03 18:03     ` Mark H Weaver
  1 sibling, 0 replies; 5+ messages in thread
From: Ian Price @ 2014-01-03 16:15 UTC (permalink / raw)
  To: Panicz Maciej Godek; +Cc: guile-user@gnu.org

Panicz Maciej Godek <godek.maciek@gmail.com> writes:

> I've checked this with other implementations. Racket, Gambit and Biwa
> Scheme were equally uninformative. Kawa's backtrace was a nightmare to
> me, but perhaps someone with more knowledge would be able to infer the
> actual location of the error. Actually, the only implementation that
> exposed the exact location was Chicken. It proves that there must be a
> way to track this information in spite of TCO.
>
It depends on just how much information you want to keep
around. Obviously, most of us don't want a full stack trace for a (let
loop () (if ... (loop))). There would simply be no (legible) way in
Scheme to write an infinite loop without proper tail recursion.

I'm not about to argue either side of this, but I will note that I added
a wishlist item for improving backtraces to the tracker a while back,
and it's free for anyone who wants to, to hack on.

See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11215.

(As for Racket, I suspect you would get better info in the gui than the
console version.)

-- 
Ian Price -- shift-reset.com

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"



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

* Re: Where is the backtrace?
  2014-01-03 13:57   ` Panicz Maciej Godek
  2014-01-03 16:15     ` Ian Price
@ 2014-01-03 18:03     ` Mark H Weaver
  1 sibling, 0 replies; 5+ messages in thread
From: Mark H Weaver @ 2014-01-03 18:03 UTC (permalink / raw)
  To: Panicz Maciej Godek; +Cc: guile-user@gnu.org

Panicz Maciej Godek <godek.maciek@gmail.com> writes:

> I've checked this with other implementations. Racket, Gambit and Biwa
> Scheme were equally uninformative. Kawa's backtrace was a nightmare to
> me, but perhaps someone with more knowledge would be able to infer the
> actual location of the error. Actually, the only implementation that
> exposed the exact location was Chicken. It proves that there must be a
> way to track this information in spite of TCO.

I suspect the reason Chicken kept the information is that in Chicken,
IIUC, tail calls are just normal C function calls, so the stack fills
until it reaches a certain size and then is garbage collected.

The solution I favor is that of MIT Scheme, which records the backtrace
as a chain of rings.  Each time a tail call is done, an entry is
recorded in the topmost ring, so between every two non-tail calls, up to
N tail calls are preserved.  If more than N tail calls are done in a
row, then the older ones are forgotten.

Hopefully we'll have this for Guile some day.

     Mark



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

end of thread, other threads:[~2014-01-03 18:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-03  2:30 Where is the backtrace? Panicz Maciej Godek
2014-01-03 10:28 ` Ian Price
2014-01-03 13:57   ` Panicz Maciej Godek
2014-01-03 16:15     ` Ian Price
2014-01-03 18:03     ` Mark H Weaver

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