How do you know if a stack overflow occurs?

BlitzMax Forums/BlitzMax Programming/How do you know if a stack overflow occurs?

Damien Sturdy(Posted 2009) [#1]
I'm working on some pretty stack intensive code (Callbacks with third party physics engines) and keep getting "Unhandled Exception:Unhandled Memory Exception Error" at seemingly random points in the code. After looking long and hard, it appears to happen at points where the stack is added to.

so how can I know if a stack overflow has occurred instead of getting the above and not knowing what it actually is I'm debugging?

Thanks,


Brucey(Posted 2009) [#2]
...at seemingly random points in the code

Are the callbacks coming from the same thread as your BlitzMax code?


grable(Posted 2009) [#3]
Also make sure that your callbacks are declared with the correct calling convention.


Damien Sturdy(Posted 2009) [#4]
Same thread. nothing special there. Unless theres something special about conventions with callbacks, there's nothing wrong there either, they work, but when things get busy anything that "creates" anything causes the above error.

Thing is, with something like Newton, the callbacks can be called a LOT, and the tipping point won't always occur at the same time, this would be why the error seems random.

I don't actually have to be using a callback to do it, can do it with pure blitzmax code- simply create a function that calls itself. Obviously this isn't something you would do in a real world application, but it'll simulate using the stack enough to overflow it.

most languages give Stack overflow errors but I can't seem to get one out of Max, it just gives the above unhelpful message.