Jump to content

WTF is a StackOverFlow Exception?

AlTech
Go to solution Solved by SnowyMus,

Stack overflows basically mean that the call stack has run out of room. One cause can be if your program is nested too deep in functions, like if you're doing something recursively, or if you've attempted to allocate too much data in the stack.

So I was trying out something and I came across a "StackOverFlowException was unhandled". What even is StackOverFlowException?

 

I can't seem to replicate it.

Judge a product on its own merits AND the company that made it.

How to setup MSI Afterburner OSD | How to make your AMD Radeon GPU more efficient with Radeon Chill | (Probably) Why LMG Merch shipping to the EU is expensive

Oneplus 6 (Early 2023 to present) | HP Envy 15" x360 R7 5700U (Mid 2021 to present) | Steam Deck (Late 2022 to present)

 

Mid 2023 AlTech Desktop Refresh - AMD R7 5800X (Mid 2023), XFX Radeon RX 6700XT MBA (Mid 2021), MSI X370 Gaming Pro Carbon (Early 2018), 32GB DDR4-3200 (16GB x2) (Mid 2022

Noctua NH-D15 (Early 2021), Corsair MP510 1.92TB NVMe SSD (Mid 2020), beQuiet Pure Wings 2 140mm x2 & 120mm x1 (Mid 2023),

Link to comment
Share on other sites

Link to post
Share on other sites

something to do with minecraft

xD 

Ryzen 5 3600 stock | 2x16GB C13 3200MHz (AFR) | GTX 760 (Sold the VII)| ASUS Prime X570-P | 6TB WD Gold (128MB Cache, 2017)

Samsung 850 EVO 240 GB 

138 is a good number.

 

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, alexboz said:

I believe stack overflow is when you have too much data in the stack, aka local variables.

Ah ok.

 

Do you know much about WMI?

Judge a product on its own merits AND the company that made it.

How to setup MSI Afterburner OSD | How to make your AMD Radeon GPU more efficient with Radeon Chill | (Probably) Why LMG Merch shipping to the EU is expensive

Oneplus 6 (Early 2023 to present) | HP Envy 15" x360 R7 5700U (Mid 2021 to present) | Steam Deck (Late 2022 to present)

 

Mid 2023 AlTech Desktop Refresh - AMD R7 5800X (Mid 2023), XFX Radeon RX 6700XT MBA (Mid 2021), MSI X370 Gaming Pro Carbon (Early 2018), 32GB DDR4-3200 (16GB x2) (Mid 2022

Noctua NH-D15 (Early 2021), Corsair MP510 1.92TB NVMe SSD (Mid 2020), beQuiet Pure Wings 2 140mm x2 & 120mm x1 (Mid 2023),

Link to comment
Share on other sites

Link to post
Share on other sites

Stack overflows basically mean that the call stack has run out of room. One cause can be if your program is nested too deep in functions, like if you're doing something recursively, or if you've attempted to allocate too much data in the stack.

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, AluminiumTech said:

Do you know much about WMI?

idk what WMI even is

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, alexboz said:

idk what WMI even is

My bad...........

Judge a product on its own merits AND the company that made it.

How to setup MSI Afterburner OSD | How to make your AMD Radeon GPU more efficient with Radeon Chill | (Probably) Why LMG Merch shipping to the EU is expensive

Oneplus 6 (Early 2023 to present) | HP Envy 15" x360 R7 5700U (Mid 2021 to present) | Steam Deck (Late 2022 to present)

 

Mid 2023 AlTech Desktop Refresh - AMD R7 5800X (Mid 2023), XFX Radeon RX 6700XT MBA (Mid 2021), MSI X370 Gaming Pro Carbon (Early 2018), 32GB DDR4-3200 (16GB x2) (Mid 2022

Noctua NH-D15 (Early 2021), Corsair MP510 1.92TB NVMe SSD (Mid 2020), beQuiet Pure Wings 2 140mm x2 & 120mm x1 (Mid 2023),

Link to comment
Share on other sites

Link to post
Share on other sites

The stack is a data type which works using last if fist out. The Wikipedia image is very clear. https://en.wikipedia.org/wiki/Stack_(abstract_data_type)

 

Every time you call a function the local variables get put (push) on a stack. If the function completes the variables can be retrieved (pop) from the stack. But if you call too many functions the stack will grow very big. This is when an exception gets thrown. It is very common that this happens if you call a function recursively.

Like this

 

function A(){

    A()

}

 

You can use recursion if you make sure it does not go too deep.

Hope this helps.

Link to comment
Share on other sites

Link to post
Share on other sites

Automatic variables are also put on the stack, so large automatic objects can also cause stack overflows:

 

void Foo()
{
	int LargeArray[10000000]; //<== possible cause of stack overflow...
  				  //...Huge objects should be dynamically 
  				  //allocated on the heap.

}

This is, of course, also true for a single object if that single object tries to do the same internally.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×