- Home /
I'm getting StackOverFlowException
Hi. I'm trying to make at first person shooter, but I'm getting trouble. I get a stackoverflowexception and for now it's pointing at main camera. I'll include links to my files. (it's only two)
https://www.dropbox.com/s/um4k40gb8lceony/MenuManager.txt https://www.dropbox.com/s/4twejp50gmgaffg/MultiplayerManager.txt
The call stack is a structure that keeps track of function call states. That is, every time a function gets called, the the program$$anonymous$$g language environment puts the instruction pointer and variables connected to function on the the stack as a way to keep track of the state of your program. When a function is finished, it gets taken off the stack, and you are returned to the state below it, which is almost always the function that originally called the function which just finished.
Usually, you get a stack overflow when more states are put on the stack than the stack can carry, hence it "overflows" with function states.
Since the stack is quite large, it would take a LOT of functions calling functions for that to happen... or, there's a high chance that a functions starts calling others or even itself recursively, infititely, until the stack overflows.
If you don't know which functions could be recursively calling each other, I suggest you stub the functions in one of your classes (comment them out), run the program again to make sure that the code you stubbed is what is causing the problem. Then, reintegrate each function and run so that you can locate which function is causing the overflow.
Answer by Ubahs · Apr 02, 2013 at 08:13 PM
You have a method that is calling itself, this will do so infinitely, until you overflow the stack - I bolded the offending lines. Server_PlayerJoinRequest, will loop back to itself forever.
[RPC]
void Server_PlayerJoinRequest(string playername, NetworkPlayer view)
{
networkView.RPC("Server_PlayerJoinRequest", RPCMode.All, playername, view);
}
Your answer
Follow this Question
Related Questions
StackOverflowException on UI Button message 0 Answers
How to ignore Overflow Exception 2 Answers
Stack Overflow in if condition. 1 Answer
Catching a Stack Overflow 1 Answer
int array overflow exception 1 Answer