Overcome stack overflow!

It’s wonderful that you can download a bundle of well-written codes for your tasks, and enjoy a beer while waiting for the program to finish! Wait, the chances are you run into troubles! Programs can only run properly and seamlessly in properly configured environment.

I was lucky enough to have found and downloaded the STIP codes from Dr. Ivan Laptev’s website for my research into action classification. Unfornately the programs were executable files (.exe) which means I CANNOT modify the codes! The problem was when I ran the executable using command line from DOS, stack overflow was reported for several of the videos. Searching over the Internet, desperately, for several tens of minutes, ultimately I figured out how I could change the stack reserves even for executable. And here it is!

Environment: Windows Vista SP1 with Visual Studio 2008 Professional Edition (Other editions of Visual Studio will also do so long as dumpbin.exe and editbin.exe are along installed)

Description: Suppose we’re playing with test.exe located at C:\. To check the stack reserve, type

…\bin>dumpbin /headers C:\test.exe

the directory should be the bin location where VS has been installed. And the “size of stack reserve” information can be found in “optional header values”. Normally when stack overflow occurs, the value should be increased to ensure enough virtual memory for stack is allocated. To do this, type

…\bin>editbin /STACK: size C:\test.exe

where size should be replaced by a decimal number. An important bit is the “size of stack reverse” displayed previously is a hexadecimal number, which requires careful computation when typing in the new size.

If the size is altered to a sufficiently large (but not exceedingly since our computers are finite machines) value, the program should be able to run again. And this is the way I force the program to finish with all my videos in the database.

Main reference: http://www.cs.nyu.edu/exact/core/doc/stackOverflow.txt

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: