Unexpected exit without output data

Blitz3D Forums/Blitz3D Programming/Unexpected exit without output data

Yue(Posted 2010) [#1]


Hello friends, I have a problem that the program takes no notice me back to the development environment without displaying any information that might be?

Last edited 2010


Yasha(Posted 2010) [#2]
Does it still do it even in Debug mode?

If so, stack overflows are one thing that could cause this behaviour. Are you using any recursive functions?


Yue(Posted 2010) [#3]
Hi, yes, it does in the mode of deporación not understand what recursive functions = (. Google does not translate well.


Yasha(Posted 2010) [#4]
A recursive function is a function that calls itself at some point:
Function recursiveFibonacci(n, itr = 1, a = 1, b = 0)
    If itr = n
        Return a
    Else
        Return recursiveFibonacci(n, itr + 1, a + b, a)
    EndIf
End Function

While this is a wonderfully elegant way to express algorithms, unfortunately every time the function is called, the previous invocation is still waiting to return the recursive value. That means it's still taking up space on the call stack. The size of the stack in Windows is preset, so if too many functions are active at once, the program will break. As an example, calling the above function with a value higher than 28761 (at least, on my computer - this might vary, I don't know) will result in a stack overflow and B3D simply exiting without any warning (the function stops returning meaningful results long before then - at 46!).

This can be caused by one of two problems:
- your function is looping infinitely (i.e. there is no check that causes it to return when it's done what you want)
- your function has a correct check, but loops too often because the check hasn't been fulfilled yet by the time the stack overflows

For example, the above example function has a check to return to the caller once it's calculated the desired value, but this is compromised if you ask for a ridiculously high value.

The other possibility is that you've got an "impure" recursive function: your function doesn't call itself, but it is being re-invoked by one of the other functions it does call somewhere along the line. This is harder to implement correctly in a language like B3D; if you're doing this I would advise rewriting that section of code.

Last edited 2010


Yue(Posted 2010) [#5]
Ok, it's amazing what I have to learn these days ...

The fact is that my program has a function to load the main menu and used the same way to load the first level, so the problem occurs when entering the first level and return to the main menu by pressing escape, then we continue with the game and this is where it crashes. Therefore verificare the respective function, and certainly every time I am more convinced than ever will be a real programmer.

And I will comment as the issue is.

I greatly appreciate your help and your time.


Yue(Posted 2010) [#6]


Hi, actually was what you have told, I have accommodated the roles and everything goes perfect.

A greeting.