[clean-list] My very first program crashes!

Fergus Henderson fjh@cs.mu.oz.au
Tue, 29 May 2001 19:27:44 +1000


On 29-May-2001, Maarten de Mol <maartenm@cs.kun.nl> wrote:
> Agreed. In this situation, a compile-time warning could easily be generated.
> (of course, I always compile with warnings off so it wouldn't help me ;-))

Such warnings should be enabled by default, of course.
(Or do you explicitly disable warnings?  If so, why??)

> >  | Mercury runtime: memory zone detstack#0 overflowed
> >  | PC at signal: 134513980 (804853c)
> >  | This may have been caused by a stack overflow, due to unbounded
> >  | recursion.
> 
> > The first two lines here are probably not especially helpful.
> > But the last line may help a lot, particularly for newcomers.
> 
> It helps in finding out *what* went wrong, but not in *where* it went wrong.

Sure.  For that, you just need to compile with debugging enabled, and run the
program in the Mercury debugger.  This will still crash as before, but this
time with an additional line in the error message:

	Last trace event was event #232993.

Then you can rerun the program in the debugger, use the debugger's "goto"
command to skip to event #232993, and then use the debugger's "stack" command
to print out the stack trace, which will identify the culprit.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.