I'm getting a stack overflow exception in my VB.NET DLL.
The call stack is 115 calls deep, and its not a buggy recursive program, but that depth of call stack is genuinely needed.
I'm wondering why it would bomb out when I imagine that recursive programs go much deeper than this. Does anyone know what contributes to the stack space being used up ? e.g. does a long string as a parameter in one of the calls contribute ?? or otherwise what else would be causing it ?
I've tried the following
- Comment out/revert recent changes but it still fails
- Reboot
- Run it multiple times, it never fails in the same place, but always in a random place
The code is single threaded at the moment and is compiled as a 64 bit process.
I have not upgraded VS for about a year so not sure what changed to cause this
I'm aware of how to fix this by launching parts of the process on different threads and then waiting for them, but that solution worries me because it's more of a workaround/hack than finding what caused it in the first place.
So looking to understand possible factors that may be causing the error and thoughts on what might contribute to the stack space filling up so quickly.
I'm sure the program would continue to error if migrated in C#, so I've tagged with C# also since the error has the same potential to happen in that language.
Structures?