[Freedos-user] Stack overflow

2012-12-20 Thread Santiago Almenara
Hello list: I am having Stack Overflow problems with this simple code under FreeDOS and OpenWatcom: #include stdio.h char a[8192]; int main() { int i; char b[8192]; for(i=0; i8192; i++) a[i]=b[i]=0; return 0; } I keep getting stack overflow problems. I know this code is very

Re: [Freedos-user] Stack overflow

2012-12-20 Thread Chris Evans
wouldnt using memset() be better ? On Dec 20, 2012, at 10:24 AM, Santiago Almenara wrote: Hello list: I am having Stack Overflow problems with this simple code under FreeDOS and OpenWatcom: #include stdio.h char a[8192]; int main() { int i; char b[8192];

Re: [Freedos-user] Stack overflow

2012-12-20 Thread Mateusz Viste
AFAIK when you use static tables they are allocated on the stack. You might want to try allocating them on the heap... To do so, simply use malloc(). char *a; a = malloc(8192); if (a == NULL) return(1); /* do your stuff */ free(a); return(0); cheers, Mateusz On 12/20/2012 07:24

Re: [Freedos-user] Stack overflow

2012-12-20 Thread Michael B. Brutman
First, the good news - Watcom includes code at the start and end of each function to detect stack overflows. It is a lot easier to debug code when you know what the root cause of the problem is. If the stack overflow were to happen and remain silent, you could have all sorts of strange

Re: [Freedos-user] Stack overflow

2012-12-20 Thread Santiago Almenara
Michael: Where can I find the default size for the watcom stack? If you use stack=4096, it means the default stack size might be much smaller than the 16384 I am using. Santiago On Thu, Dec 20, 2012 at 2:42 PM, Michael B. Brutman mbbrut...@brutman.comwrote: First, the good news - Watcom

Re: [Freedos-user] Stack overflow

2012-12-20 Thread Tom Ehlert
Hello list: asking programming errors on a mailing list that is focused on operating system development is considered BAD. I am having Stack Overflow problems with this simple code under FreeDOS and OpenWatcom: #include stdio.h char a[8192]; int main() { int i; char b[8192];

Re: [Freedos-user] Stack overflow

2012-12-20 Thread Rugxulo
Hi, On Thu, Dec 20, 2012 at 2:28 PM, Santiago Almenara almen...@gmail.com wrote: Where can I find the default size for the watcom stack? Dunno. I think it used to be 4 kb for 16-bit targets, but they may?? have increased it to 16 kb in the meantime.

Re: [Freedos-user] Stack overflow

2012-12-20 Thread Ralf A. Quint
At 12:58 PM 12/20/2012, Louis Santillan wrote: The Memory Model (Tiny vs. Small vs. Compact vs. Medium vs. Large, .COM vs. .EXE) of the compiler could be causing the issue. Some compilers used to default to Small. What compiler flags are you using? Even in the TINY model, there is no reason to

Re: [Freedos-user] Stack overflow

2012-12-20 Thread Michael B. Brutman
On 12/20/2012 2:41 PM, Tom Ehlert wrote: asking programming errors on a mailing list that is focused on operating system development is considered BAD. I don't think we have enough developers (OS or application) or enough list traffic where we can afford to be picky ... Mike

Re: [Freedos-user] Stack overflow

2012-12-20 Thread Michael B. Brutman
On 12/20/2012 3:11 PM, Ralf A. Quint wrote: At 12:58 PM 12/20/2012, Louis Santillan wrote: The Memory Model (Tiny vs. Small vs. Compact vs. Medium vs. Large, .COM vs. .EXE) of the compiler could be causing the issue. Some compilers used to default to Small. What compiler flags are you using?

Re: [Freedos-user] Stack overflow

2012-12-20 Thread Tom Ehlert
At 12:58 PM 12/20/2012, Louis Santillan wrote: The Memory Model (Tiny vs. Small vs. Compact vs. Medium vs. Large, .COM vs. .EXE) of the compiler could be causing the issue. Some compilers used to default to Small. What compiler flags are you using? Even in the TINY model, there is no reason

Re: [Freedos-user] Stack overflow

2012-12-20 Thread Tom Ehlert
asking programming errors on a mailing list that is focused on operating system development is considered BAD. I don't think we have enough developers (OS or application) or enough list traffic where we can afford to be picky ... this is stillnot the 'programming for dummies' mailing list.

[Freedos-user] Stack overflow

2012-12-20 Thread bruce.bowman tds.net
Static/global variables are allocated from the heap. Dynamic variables (like the b array in your code) are pushed on the stack. Either use compiler directives to increase stack space or make both arrays static. This is not a FreeDOS problem and should not have been posted to this list. Bruce