www.digitalmars.com         C & C++   DMDScript  

D - Deep recursion problem

reply "Lars Ivar Igesund" <larsivi stud.ntnu.no> writes:
When doing some testing with my ddepcheck app, I found
out that to deep recursion isn't handled perfectly by D/dmd. If
the recursion is infinite, it crashes very quickly. If I try to limit
it, I get an Acces Violation at a certain depth (18 with an
optimized build, deeper when not optimized).

The quick crash result in no message whatsoever, but I would
have expected an Out of Memory error. The access violation
don't say anything about what is violated or where. Better
diagnostic messages would have been helpful.

(The problems helped me make a more robust recursive app,
btw. The recursion can no longer be infinite.)

Lars Ivar Igesund
Nov 12 2003
next sibling parent "Walter" <walter digitalmars.com> writes:
D shouldn't have any different recursion issues than C or C++.

"Lars Ivar Igesund" <larsivi stud.ntnu.no> wrote in message
news:bost27$1mcg$1 digitaldaemon.com...
 When doing some testing with my ddepcheck app, I found
 out that to deep recursion isn't handled perfectly by D/dmd. If
 the recursion is infinite, it crashes very quickly. If I try to limit
 it, I get an Acces Violation at a certain depth (18 with an
 optimized build, deeper when not optimized).

 The quick crash result in no message whatsoever, but I would
 have expected an Out of Memory error. The access violation
 don't say anything about what is violated or where. Better
 diagnostic messages would have been helpful.

 (The problems helped me make a more robust recursive app,
 btw. The recursion can no longer be infinite.)

 Lars Ivar Igesund
Nov 12 2003
prev sibling parent "Matthew Wilson" <matthew-hat -stlsoft-dot.-org> writes:
I just compiled and ran the following code, and it descended to a depth of
51728 before reporting "Error: Access Violation"


import std.c.stdio;

void fn(int i)
{
 printf("%d\n", i);

 fn(1 + i);
}

int main()
{
 fn(0);

 return 0;
}

Hope that helps

"Lars Ivar Igesund" <larsivi stud.ntnu.no> wrote in message
news:bost27$1mcg$1 digitaldaemon.com...
 When doing some testing with my ddepcheck app, I found
 out that to deep recursion isn't handled perfectly by D/dmd. If
 the recursion is infinite, it crashes very quickly. If I try to limit
 it, I get an Acces Violation at a certain depth (18 with an
 optimized build, deeper when not optimized).

 The quick crash result in no message whatsoever, but I would
 have expected an Out of Memory error. The access violation
 don't say anything about what is violated or where. Better
 diagnostic messages would have been helpful.

 (The problems helped me make a more robust recursive app,
 btw. The recursion can no longer be infinite.)

 Lars Ivar Igesund
Nov 12 2003