I've got a c# program which is using a c++/cli managed dll. The dll contains a lot of legacy code, consisting of quite a few win32 windows.
Problem is, the windows in the dll need a bit more stackspace than average cough. Since these are not background processes but win32 api I need to enlarge the stack size of the GUI thread (at least I think the win32 api in the dll will use the main gui process).
So I need a way to enlarge the size of the GUI thread in a c# process.
Since I found no settings to achieve this I tried editbin /STACK from the command line, which works. Problem is, it only works in the command line, if I try to enter it as post-build-step for some reason the stack size of the binary does not change, even though the postbuild step is properly executed and throws no error :(
editbin.exe /STACK:2097152 $(TargetPath)
(Editbin.exe is in the path, and there is no error in the output window)
So how do I get more stack size for my c++ dll?
[Update]
I noticed a problem using editbin.exe.
This does not work, neither in command line nor as post build step:
editbin.exe /STACK:2097152 c:\some\path\bin\release\app.exe
This does work in command line, but not as build step:
editbin.exe /STACK:2097152 app.exe
But I need it to work as post build step. I tried to put it into a batch file, echo'd to make sure call and working dir are ok, but still it does not work. Strange.
As stated in the comments: Stack underflow means having the stack pointer to point to an address below the beginning of the stack ("below" for architectures where the stack grows from low to high). c.
Stack overflows corrupt memory on the stack. This means that values of local variables, function arguments, and return addresses are affected. Whereas heap overflows refer to overflows that corrupt memory located on the heap. Global variables and other program data are affected.
Usually, when a stack overflow error occurs, the program crashes and can either freeze or close the program. Any unsaved data or work is lost. The stack overflow error is often caused by an infinite loop or the creation of variables larger than the size of the call stack.
Underflow happens when we try to pop an item from an empty stack. Overflow happens when we try to push more items on a stack than it can hold. An error is a mistake that is probably unrecoverable. An exception is an error that can often be handled, so the program can recover.
This shouldn't work, odd that you don't get a build error. The path isn't set correctly to be able to use the tool in a C# build. It does work from the command line, the Visual Studio Command Prompt uses the config for a C/C++ project. This post-build command worked properly in VS2008:
set path=%path%;$(DevEnvDir);$(DevEnvDir)..\..\vc\bin
editbin.exe /STACK:2097152 "$(TargetPath)"
Also note the double-quotes around the target path macro to deal with spaces.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With