[alt.msdos.programmer] Stack Size question

hlison@bbn.com (Herb Lison) (07/05/90)

I'm having a problem allocating a larger stack than the default.  I've
got a large program, approximately 330 K for the .EXE file.  When I
increase the stack size from 2K to 8K with the EXEMOD utility, the
program immediately exits with a stack overflow error (R6000).  Running
the program with a smaller stack results in a stack overflow error later
on.  I've tried using overlays, but this doesn't seem to make any
difference.

Anyone have any ideas on what do here?  There's not much more code that
I can hack away and I'm not going to be able to use extended memory.
Thanks in advance.

Herb Lison

pajerek@usenet@kadsma (Don Pajerek) (07/06/90)

In article <14298@silica.BBN.COM> hlison@bbn.com (Herb Lison) writes:
>I'm having a problem allocating a larger stack than the default.  I've
>got a large program, approximately 330 K for the .EXE file.  When I
>increase the stack size from 2K to 8K with the EXEMOD utility, the
>program immediately exits with a stack overflow error (R6000).  Running
>the program with a smaller stack results in a stack overflow error later
>on.  I've tried using overlays, but this doesn't seem to make any
>difference.
>
>Anyone have any ideas on what do here?  There's not much more code that
>I can hack away and I'm not going to be able to use extended memory.
>Thanks in advance.
>
>Herb Lison


Have you tried using a /stack:8192 linker option? This will at least
tell you at link time whether the 8K stack is too big.  If it is,
you'll have to make room for it by moving some data items out of the
default data segment into a separate data segment (using the 'far'
keyword).

Enjoy,
Don Pajerek

prk@planet.bt.co.uk (Peter Knight) (08/20/90)

hlison@bbn.com (Herb Lison) writes:

>I'm having a problem allocating a larger stack than the default.  I've
>got a large program, approximately 330 K for the .EXE file.  When I
>increase the stack size from 2K to 8K with the EXEMOD utility, the
>program immediately exits with a stack overflow error (R6000).  Running
>the program with a smaller stack results in a stack overflow error later
>on.  I've tried using overlays, but this doesn't seem to make any
>difference.

>Anyone have any ideas on what do here?  There's not much more code that
>I can hack away and I'm not going to be able to use extended memory.
>Thanks in advance.

>Herb Lison

You do not say which compiler and linker you are using, but for increasing 
the stack size using of Microsoft compiled code, eg C v5.1, you can use 
the link option /ST:XXXX where XXXX is the (hex) size of your desired
stack.  If exemod doesn't work, it is likely that the version you are using
is not compatible with the compiler and linker that you are using.

Peter Knight 
BT Research

#include <standard\disclaimer.h>

bryan@stiatl.UUCP (Bryan Donaldson) (08/21/90)

prk@planet.bt.co.uk (Peter Knight) writes:
>hlison@bbn.com (Herb Lison) writes:
>>I'm having a problem allocating a larger stack than the default.  I've
>>got a large program, approximately 330 K for the .EXE file.  When I
>>increase the stack size from 2K to 8K with the EXEMOD utility, the
>>program immediately exits with a stack overflow error (R6000).  Running
>>the program with a smaller stack results in a stack overflow error later
>>on.  I've tried using overlays, but this doesn't seem to make any
>>difference.
>>Anyone have any ideas on what do here?  There's not much more code that
>>I can hack away and I'm not going to be able to use extended memory.
>>Thanks in advance.
>>Herb Lison
>You do not say which compiler and linker you are using, but for increasing 
>the stack size using of Microsoft compiled code, eg C v5.1, you can use 
>the link option /ST:XXXX where XXXX is the (hex) size of your desired
>stack.  If exemod doesn't work, it is likely that the version you are using
>is not compatible with the compiler and linker that you are using.
>Peter Knight 
>BT Research

Often, you'll have to add the additional option -Gt to move some of your
data items out of the default data segment.

Since the stack and default data usually occupy the same segment, 
sometimes when you expand the stack you'll get the message ,
"stack plus data exceeds 64K."  The way we found to get around
this is to use the -Gt switch, with a value of 16, 32, or 64; which
ever would move enough of the default data to another segment. 

(Basically we'd try values until they didn't produce the error anymore.)

Check to see if your linker is producing a message like to one above.
Ignoring this message will cause stack overflows and other odd
behaviour.

BGD


-- 
Bryan Donaldson                                             gatech!stiatl!bryan
Sales Technologies, Inc
3399 Peachtree Rd, NE
Atlanta, GA  (404) 841-4000