Stack Overflow Exception
-
Hi I'm getting an unhandled exception in MSVCRTD.DLL Stack Overflow. Basically I can't see where it's coming from. The below try block call's itself recursively and doing some other stuff along the way until a global count has been reached. The only exception i can trap is the catch all. Is there anyway of determining the type of exception? I can't work out where it is being thrown from? :( code: try { AddNextCallToPlayList(); } catch( CMemoryException* e ) { LOG_ERROR(_T("CMem\n")); // Handle the out-of-memory exception here. } catch( CFileException* e ) { // Handle the file exceptions here. LOG_ERROR(_T("CFile\n")); } catch( CException* e ) { // Handle all other types of exceptions here. LOG_ERROR(_T("CException \n")); } catch(_com_error e) { LOG_ERROR(_T("catch com\n")); } catch(...) //__except(EXCEPTION_EXECUTE_HANDLER) { LOG_ERROR(_T("catch all\n")); }
-
Hi I'm getting an unhandled exception in MSVCRTD.DLL Stack Overflow. Basically I can't see where it's coming from. The below try block call's itself recursively and doing some other stuff along the way until a global count has been reached. The only exception i can trap is the catch all. Is there anyway of determining the type of exception? I can't work out where it is being thrown from? :( code: try { AddNextCallToPlayList(); } catch( CMemoryException* e ) { LOG_ERROR(_T("CMem\n")); // Handle the out-of-memory exception here. } catch( CFileException* e ) { // Handle the file exceptions here. LOG_ERROR(_T("CFile\n")); } catch( CException* e ) { // Handle all other types of exceptions here. LOG_ERROR(_T("CException \n")); } catch(_com_error e) { LOG_ERROR(_T("catch com\n")); } catch(...) //__except(EXCEPTION_EXECUTE_HANDLER) { LOG_ERROR(_T("catch all\n")); }
-
Either remove the catchall or set stack overflow exceptions to break into the debugger. Then you can look at the call stack. Tim Smith I'm going to patent thought. I have yet to see any prior art.
The problem is that it runs through this code at least 137 times without causing a problem. If i remove the catch all the stack is showing the current function but no where near anything that could cause a problem. How do i set set stack overflow exceptions? Your comments are appreciated Carl
-
The problem is that it runs through this code at least 137 times without causing a problem. If i remove the catch all the stack is showing the current function but no where near anything that could cause a problem. How do i set set stack overflow exceptions? Your comments are appreciated Carl
crandall wrote: The problem is that it runs through this code at least 137 times without causing a problem. It sounds like the stack overflow is being caused by unbounded recursion. Check to see if this function can be called recursively somehow, and if it is, make sure it doesn't get called too many times.
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
crandall wrote: The problem is that it runs through this code at least 137 times without causing a problem. It sounds like the stack overflow is being caused by unbounded recursion. Check to see if this function can be called recursively somehow, and if it is, make sure it doesn't get called too many times.
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
It is being called recursively. How can i achieve this successfully? Carl
-
It is being called recursively. How can i achieve this successfully? Carl
You need to include some code to prevent the recursion from going too deep; you need to reduce the number of times the function is called recursively. How you do this is up to you, but you may need to convert the algorithm to an iterative one. If you can limit the depth of the recursion without ruining the algorithm then that would be the best option.
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"