[mercury-users] notify of recursion depth exceeded (stack overflow)
Julien Fischer
juliensf at csse.unimelb.edu.au
Fri Oct 8 00:43:31 AEDT 2010
Hi,
On Wed, 6 Oct 2010, Vladimir Gubarkov wrote:
> If we compile mercury source with default settings (simple mmc file.m) then
> in case of stack overflow program will silently exit (with no error at all
> (at least at win),
Do you mean this is occurring on Windows?
> i believe that this is because stack overflow happens on C-level).
>
> On the other side if compiling with stseg grade then program will hang with
> a lot of memory consumed. My question is - is there some compile options to
> have descriptive error like: "Stack overflow at pred some_pred: recursion
> limit 1000 reached" or smth like this.
There's nothing that will cause the compiler to do something like that.
There is an option, for the high-level C backend only, that will cause
it to emit a warning about any directly recursive calls that are not
tail-calls. That option is: --warn-non-tail-recursion.
If the stack overflow is being caused by a procedure going into an
infinite loop then using one of the termination analysers or the
loop_check pragma might also help.
There is also a library predicate,
exception.throw_if_near_stack_limits/0, that can be used to check
whether the stacks are close to being exhausted.
(It only works for the low-level C grades though.)
You could also try enabling the optimization --optimize-constructor-last-call.
Julien.
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to: mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions: mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the users
mailing list