• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Zobtzler · Apr 02, 2013 at 06:03 PM · exceptionstackstackoverflowoverflow

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

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hoy_smallfry · Apr 02, 2013 at 06:57 PM 3
Share

The call stack is a structure that keeps track of function call states. That is, every time a function gets called, the the programming 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.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

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);
 }
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image KLEPSTER · Aug 07, 2016 at 08:09 AM 0
Share

thnx you Ubahs

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

14 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

StackOverflowException on UI Button message 0 Answers

Editor Crashes when spawning 1k objects 2 Answers

How to ignore Overflow Exception 2 Answers

int array overflow exception 1 Answer

Stack Overflow in if condition. 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges