From: Colin Watters on

"Mike" <SulfateIon(a)gmail.com> wrote in message
news:1191889419.551174.176640(a)19g2000hsx.googlegroups.com...
> On Oct 9, 6:59 am, Terence <tbwri...(a)cantv.net> wrote:
>> I have met the stack overflow problem.
>> "Stack Overflow: Error 2000"
>>
>> With me it only occured in two cases, and ONLY in operating systems of
>> Windows 2000 and XP that had been updated on-line by Microsoft,
>> applying "security patches".
>> These apparently carve off some user stack to work with; I calculate
>> about #4000 hex worth.
>>
>> Case 1) One program calling another as a daughter process (the caller
>> fails)
>> Case 2) A program calling SYSTEM services.
>>
>> My solution was to take the executable and add another #4000 (hex)
>
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Can you explain more clearly?
> Or, give me an example.

There is a utility that is distributed with CVF called EDITBIN. Type

EDITBIN /?

at a command prompt to verify you have it and to see its range of arguments.

Among other things, EDITBIN allows you to change the stack size of a
finished program held in a .EXE file. Using it is therefore an alternative
to re-linking with a different stack size specified.

See also DUMPBIN which allows a .EXE file to be inspected, notably to reveal
the current stack size.

--
Qolin

Email: my qname at domain dot com
Domain: qomputing


From: Terence on
For command line executables I use the following batch file
(Stack.bat):-

\exemod2 %1 /stack 0c00

Here, the argument is the name of the linked executable.
The size of the stack is by default #0800, so I set the stack now to
#0c00 (4k more).

Exemod2.exe is the EXEMOD.exe program from Microsoft, PRE-MODIFIED
itself with the same stack increase process above (on another non-XP,
non-NT machine, then copied wildly), since it too, will fail for the
same stack overflow reason, without having changed it first.
I know why people love or hate Microsoft!

For CVF, I generally use a binary viewing program to view and edit the
stack size in the .exe file header, but the EDITBIN function mentioned
should also work (I never used it).

I find that any program that calls another, or executes a SYSTEM
service needs this, but not otherwise, nor straight-forward daughter
programs.

















On Oct 9, 4:48 pm, "Colin Watters" <qolin.see_signat...(a)nowhere.co.uk>
wrote:
> "Mike" <Sulfate...(a)gmail.com> wrote in message
>
> news:1191889419.551174.176640(a)19g2000hsx.googlegroups.com...
>
>
>
> > On Oct 9, 6:59 am, Terence <tbwri...(a)cantv.net> wrote:
> >> I have met the stack overflow problem.
> >> "Stack Overflow: Error 2000"
>
> >> With me it only occured in two cases, and ONLY in operating systems of
> >> Windows 2000 and XP that had been updated on-line by Microsoft,
> >> applying "security patches".
> >> These apparently carve off some user stack to work with; I calculate
> >> about #4000 hex worth.
>
> >> Case 1) One program calling another as a daughter process (the caller
> >> fails)
> >> Case 2) A program calling SYSTEM services.
>
> >> My solution was to take the executable and add another #4000 (hex)
>
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > Can you explain more clearly?
> > Or, give me an example.
>
> There is a utility that is distributed with CVF called EDITBIN. Type
>
> EDITBIN /?
>
> at a command prompt to verify you have it and to see its range of arguments.
>
> Among other things, EDITBIN allows you to change the stack size of a
> finished program held in a .EXE file. Using it is therefore an alternative
> to re-linking with a different stack size specified.
>
> See also DUMPBIN which allows a .EXE file to be inspected, notably to reveal
> the current stack size.
>
> --
> Qolin
>
> Email: my qname at domain dot com
> Domain: qomputing


From: Mike on
On Oct 9, 2:48 pm, "Colin Watters" <qolin.see_signat...(a)nowhere.co.uk>
wrote:
> "Mike" <Sulfate...(a)gmail.com> wrote in message
>
> news:1191889419.551174.176640(a)19g2000hsx.googlegroups.com...
>
>
>
>
>
> > On Oct 9, 6:59 am, Terence <tbwri...(a)cantv.net> wrote:
> >> I have met the stack overflow problem.
> >> "Stack Overflow: Error 2000"
>
> >> With me it only occured in two cases, and ONLY in operating systems of
> >> Windows 2000 and XP that had been updated on-line by Microsoft,
> >> applying "security patches".
> >> These apparently carve off some user stack to work with; I calculate
> >> about #4000 hex worth.
>
> >> Case 1) One program calling another as a daughter process (the caller
> >> fails)
> >> Case 2) A program calling SYSTEM services.
>
> >> My solution was to take the executable and add another #4000 (hex)
>
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > Can you explain more clearly?
> > Or, give me an example.
>
> There is a utility that is distributed with CVF called EDITBIN. Type
>
> EDITBIN /?
>
> at a command prompt to verify you have it and to see its range of arguments.
>
> Among other things, EDITBIN allows you to change the stack size of a
> finished program held in a .EXE file. Using it is therefore an alternative
> to re-linking with a different stack size specified.
>
> See also DUMPBIN which allows a .EXE file to be inspected, notably to reveal
> the current stack size.
>
> --
> Qolin
>
> Email: my qname at domain dot com
> Domain: qomputing- Hide quoted text -
>
> - Show quoted text -

following is the result of dumpbin
Dump of file sv1p0b.exe

PE signature found

File Type: EXECUTABLE IMAGE

FILE HEADER VALUES
14C machine (i386)
4 number of sections
470C1A8B time date stamp Wed Oct 10 08:19:23 2007
0 file pointer to symbol table
0 number of symbols
E0 size of optional header
10F characteristics
Relocations stripped
Executable
Line numbers stripped
Symbols stripped
32 bit word machine

OPTIONAL HEADER VALUES
10B magic #
6.00 linker version
BD000 size of code
43169000 size of initialized data
0 size of uninitialized data
99470 RVA of entry point
1000 base of code
BE000 base of data
400000 image base
1000 section alignment
1000 file alignment
4.00 operating system version
0.00 image version
4.00 subsystem version
0 Win32 version
43227000 size of image
1000 size of headers
207B0C checksum
3 subsystem (Windows CUI)
0 DLL characteristics
0 size of stack reserve
0 size of stack commit
100000 size of heap reserve
1000 size of heap commit
0 loader flags
10 number of directories
0 [ 0] RVA [size] of Export Directory
C3FAC [ 28] RVA [size] of Import Directory
0 [ 0] RVA [size] of Resource Directory
0 [ 0] RVA [size] of Exception Directory
0 [ 0] RVA [size] of Certificates Directory
0 [ 0] RVA [size] of Base Relocation Directory
BE160 [ 1C] RVA [size] of Debug Directory
0 [ 0] RVA [size] of Architecture Directory
0 [ 0] RVA [size] of Special Directory
0 [ 0] RVA [size] of Thread Storage Directory
0 [ 0] RVA [size] of Load Configuration Directory
0 [ 0] RVA [size] of Bound Import Directory
BE000 [ 160] RVA [size] of Import Address Table
Directory
0 [ 0] RVA [size] of Delay Import Directory
0 [ 0] RVA [size] of Reserved Directory
0 [ 0] RVA [size] of Reserved Directory


SECTION HEADER #1
.text name
BC05F virtual size
1000 virtual address
BD000 size of raw data
1000 file pointer to raw data
0 file pointer to relocation table
0 file pointer to line numbers
0 number of relocations
0 number of line numbers
60000020 flags
Code
Execute Read

RAW DATA #1
00401000: 55 8B EC 83 EC 2C 53 56 57 8B 45 08 8B 1D 9C E1
U....,SVW.E.....
00401010: 4B 00 89 1D 3C C0 5F 00 8B 1D 98 E1 4B 00 89 1D
K...<._.....K...
00401020: 1C C0 5F 00 8B 1D 94 E1 4B 00 89 1D 40 C0 5F
00 .._.....K...@._.
00401030: 8B 1D 90 E1 4B 00 89 1D 20 C0 5F 00 8B 1D 8C
E1 ....K... ._.....
.....
==============================================


In the help of Compaq Visual Fortran, it shows :

EDITBIN Option /STACK
This option sets the size of the stack in bytes and takes arguments in
decimal or C-language notation. The /STACK option applies only to an
executable file. This option takes the following form:

/STACK:reserve[,commit]
The reserve argument specifies the total stack allocation in virtual
memory. EDITBIN rounds up the specified value to the nearest 4 bytes.
The optional commit argument is subject to interpretation by the
operating system. On Windows NT 4 and Windows 2000 systems, commit
specifies the amount of physical memory to allocate at a time.
Committed virtual memory causes space to be reserved in the paging
file. A higher commit value saves time when the application needs more
stack space but increases the memory requirements and possibly startup
time.

I use :
editbin/stack:0xFFFFFFFF sv1p0b.exe
after the exe is generated by CVF.
Now it shows "forrtl: severe(157): program exception-access violation"

I also set the stack in GUI of CVF, which is in "Project
setting..Link...Output". It also shows "forrtl: severe(157): program
exception-access violation"

I also change the stacksize to be about 50000000 which is a bit larger
than 43227000 (size of image). Same error happens.


Mike

From: Mike on
On Oct 9, 3:35 pm, Terence <tbwri...(a)cantv.net> wrote:
> For command line executables I use the following batch file
> (Stack.bat):-
>
> \exemod2 %1 /stack 0c00
>
> Here, the argument is the name of the linked executable.
> The size of the stack is by default #0800, so I set the stack now to
> #0c00 (4k more).
>
> Exemod2.exe is the EXEMOD.exe program from Microsoft, PRE-MODIFIED
> itself with the same stack increase process above (on another non-XP,
> non-NT machine, then copied wildly), since it too, will fail for the
> same stack overflow reason, without having changed it first.
> I know why people love or hate Microsoft!
>
> For CVF, I generally use a binary viewing program to view and edit the
> stack size in the .exe file header, but the EDITBIN function mentioned
> should also work (I never used it).

How to edit and stack size ?


From: Colin Watters on

"Mike" <SulfateIon(a)gmail.com> wrote in message
news:1191980696.066318.97550(a)y42g2000hsy.googlegroups.com...

<snip>

> following is the result of dumpbin
> Dump of file sv1p0b.exe
>
> PE signature found
>
> File Type: EXECUTABLE IMAGE
>

<snip>

> 0 size of stack reserve
> 0 size of stack commit

....If we believe what DUMPBIN is saying here, your .exe has a stack size of
zero. That will cause the sort of problem you are seeing. But I wonder if
dumpbin is being confused?

<snip>

> In the help of Compaq Visual Fortran, it shows :
>
> EDITBIN Option /STACK
> This option sets the size of the stack in bytes and takes arguments in
> decimal or C-language notation. The /STACK option applies only to an
> executable file. This option takes the following form:
>
> /STACK:reserve[,commit]
> The reserve argument specifies the total stack allocation in virtual
> memory. EDITBIN rounds up the specified value to the nearest 4 bytes.
> The optional commit argument is subject to interpretation by the
> operating system. On Windows NT 4 and Windows 2000 systems, commit
> specifies the amount of physical memory to allocate at a time.
> Committed virtual memory causes space to be reserved in the paging
> file. A higher commit value saves time when the application needs more
> stack space but increases the memory requirements and possibly startup
> time.
>
> I use :
> editbin/stack:0xFFFFFFFF sv1p0b.exe
> after the exe is generated by CVF.
> Now it shows "forrtl: severe(157): program exception-access violation"
>
> I also set the stack in GUI of CVF, which is in "Project
> setting..Link...Output". It also shows "forrtl: severe(157): program
> exception-access violation"
>
> I also change the stacksize to be about 50000000 which is a bit larger
> than 43227000 (size of image). Same error happens.
>
>
> Mike
>

The trick when conducting experiments is to observe the results. Use DUMPBIN
on the exe after each of the above operations, to verify they are having the
effect you expect. When you can relyably set the stack size to any required
value, then exercise the sensable range of stack sizes to find one that
works. A 'sensable' range is somewhere between 2 GBytes minus the .exe's
image size as an upper limit, and a bit above zero as a lower limit.

--
Qolin

Email: my qname at domain dot com
Domain: qomputing