🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: alt.msdos.programmer
4 messages
4 total messages Started by C Wayne Huling Sun, 04 Oct 1992 06:35
Stack Overflow in Turbo C
#681
Author: C Wayne Huling
Date: Sun, 04 Oct 1992 06:35
5 lines
610 bytes
I am using turbo C, and am having a stack overflow, my books tell me how to 
find the problem, but now how to solve the problem.  Any suggestions?


		Wayne
Re: Stack Overflow in Turbo C
#682
Author: haydedr
Date: Sun, 04 Oct 1992 17:12
30 lines
1450 bytes
In article <WAYNE.92Oct4013500@dew.cs.odu.edu>, wayne@dew.cs.odu.edu (C Wayne Huling) writes:
> I am using turbo C, and am having a stack overflow, my books tell me how to 
> find the problem, but now how to solve the problem.  Any suggestions?


Well, you could increase your stack size.  To do this in Turbo C++
version 3.0 for DOS (I'll bet it's the same, though, for all versions
of Turbo C), you have to set the global variable _stklen, declared in 
DOS.H, to a new value.  For instance,

/*-----------------------------------*/
#include <stdio.h>
#include <dos.h>


extern unsigned _stklen = 543210U;

int main(void)
{
   printf("The stack size is %u\n", _stklen);
   return 0;
}
/*-----------------------------------*/

That should do it.  If you increase your stack to the size I used
above, and you still overflows, then you may want to check your code
for some infinite loops or other things of that nature.

Cheers,
Ross Hayden                          HAYDEDR@WKUVX1.BITNET
Re: Stack Overflow in Turbo C
#685
Author: Jeff Kellam
Date: Mon, 05 Oct 1992 12:45
20 lines
1101 bytes
In article <WAYNE.92Oct4013500@dew.cs.odu.edu> wayne@dew.cs.odu.edu (C Wayne Huling) writes:
>I am using turbo C, and am having a stack overflow, my books tell me how to 
>find the problem, but now how to solve the problem.  Any suggestions?
>
>
>		Wayne

There are three ways to eliminate a stack overflow problem.

1)  Make more of the data static, either via the static keyword, or moving
it outside the scope of the function.

2)  Reduce the number of recursions.  If your program doesn't have recursions,
    this probably won't help.

3)  Increase the stack size.  See Turbo's Library Reference (global variable
    section) for more information.

Jeff Kellam
 
Re: Stack Overflow in Turbo C
#697
Author: Jerzy Tarasiuk
Date: Tue, 06 Oct 1992 14:28
12 lines
1145 bytes
>>>>> On 4 Oct 92 12:12:17 CDT, haydedr@wkuvx1.bitnet said:
h> In article <WAYNE.92Oct4013500@dew.cs.odu.edu>, wayne@dew.cs.odu.edu (C Wayne Huling) writes:
> I am using turbo C, and am having a stack overflow, my books tell me how to 
> find the problem, but now how to solve the problem.  Any suggestions?
h> Well, you could increase your stack size.  To do this in Turbo C++
...
h> extern unsigned _stklen = 543210U;

Note unsigned has range from 0 to 0xFFFF(=65535U), don't try use
bigger values because compiler will truncate high-order bits. 
Also note not every memory model allows 64kB stack.
Cheers, Jerzy
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads