[racket] Exception Stack Trace Troubles

From: Chad Albers (calbers at neomantic.com)
Date: Sun Jun 24 09:01:02 EDT 2012

Hi Eli,

Thanks for you help.  Unfortunately, it doesn't seem to work.  I
literally cut the code and pasted in a rkt file with #lang racket at
the top.  I ran it with the racket CLI, and received: '()

Should I be invoking the CLI with some option?  Any other ideas?


On Sun, Jun 24, 2012 at 2:08 PM, Eli Barzilay <eli at barzilay.org> wrote:
> A few minutes ago, Chad Albers wrote:
>> Hi,
>> Is there some sort of 'secret' to acquiring the stack trace of an
>> exception?  It is my understanding that when an exception is raised
>> with the 'error' procedure in creates a exn:fail structure that has
>> a message field and a continuation-marks field.  Presumably the
>> stack trace is in the continuation-marks field.  To actually get the
>> stack trace I need to call the following:
>> (continuation-mark-set->context (exn-continuation-marks exception))
> This should work -- for example, I see a stack trace with:
>  (with-handlers ([void (λ (e) (continuation-mark-set->context
>                                (exn-continuation-marks e)))])
>    (+ 1 "two"))
>> However, whenever I call this, it yields an empty list: () - Not a
>> stack trace.
> That can happen from running code in threads which start from an empty
> context.  For example, doing the above in a thread:
>  (thread (λ () (printf "~s\n" ...same...)))
> shows an empty trace.
> --
>          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
>                    http://barzilay.org/                   Maze is Life!

Posted on the users mailing list.