Stack overflow from embedded DLL called from a managed application

I get the shameful exception 0xC00000FD (stack overflow) from my application when called in my native DLL. This is run from a C # managed application in Windows CE 5 (SH4 processor). Compiling the same DLL for Windows XP using the same managed application, and everything works fine (no overflow). The procedure in the DLL makes a very complex recursion that ultimately causes an overflow, but again, it works fine on a PC.

It seems I just need to adjust the stack size when creating the DLL? I believe that the default stack size for CE and XP is 1 MB when using the Visual C compiler (I use Visual Studio 2005, if that matters). If they both default to the same size, I'm not sure why one of them is overflowing and the other is not. I tried setting the stack size with the compiler flag / F and the linker flag / STACK, but that didn't seem to do anything. It is also not entirely clear to me that I can specify the stack size in the DLL, but the executable should install it. But if that is the case, then how would I configure the stack size for my managed process to use when calling the native DLL?

+4
source share
1 answer

Here is a link to a discussion of memory architecture in Windows CE.

Ultimately, you can do very little to adjust the stack size programmatically or at compile time; The OS will vary depending on a number of factors, including memory availability. Setting the stack size with / F only sets the default value, which can (and will often be) ignored by the OS. And / F doesn't work on .DLL at all; it only works when compiling an executable file ..LLL do not have a stack; which belongs to the thread and (ultimately) the process.

Maybe it's time to go back to the drawing board to remove the recursion.

+4
source

All Articles