🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.os.msdos.programmer
8 messages
8 total messages Started by Eric Prebys Tue, 07 Nov 1995 19:03
MS C Compiler bug
#7877
Author: Eric Prebys
Date: Tue, 07 Nov 1995 19:03
33 lines
1570 bytes
We are compiling software on a 486 using the Microsoft C compiler,
version 7.0.  The following program

=========================================================
int main(int, char **);

int main(int argc, char **argv)
{
float aaabbb[2][500];
exit(0);
}
==========================================================

compiles, but causes the error

R6000 - stack overflow

when run.  The problem goes away if the array is made smaller, but
this array shouldn't cause any problems.  Does anyone have any 
suggestions?  The problem is independent of which memory model
I use or whether or not I try to initialize the array (or
any other switch or operation I can think of).

						                         Thanks,
                               Eric



* Eric J. Prebys, Asst. Prof. | Phone:  (609) 258-4910, FAX: -6360     *
* Physics Department          | Email: prebys@puhep1.princeton.edu     *
* Princeton University        | WWW: http://www.princeton.edu/~prebys/ *
* Princeton, NJ 08544         |                                        *
Re: MS C Compiler bug
#7878
Author: Robert Fry
Date: Wed, 08 Nov 1995 00:40
35 lines
1610 bytes
Eric Prebys <prebys@puhep1.princeton.edu> writes:

>We are compiling software on a 486 using the Microsoft C compiler,
>version 7.0.  The following program

>=========================================================
>int main(int, char **);

>int main(int argc, char **argv)
>{
>float aaabbb[2][500];
>exit(0);
>}
>==========================================================

>compiles, but causes the error

>R6000 - stack overflow

>when run.  The problem goes away if the array is made smaller, but
>this array shouldn't cause any problems.  Does anyone have any 
>suggestions?  The problem is independent of which memory model
>I use or whether or not I try to initialize the array (or
>any other switch or operation I can think of).

I haven't looked at MS C for over a year, but I would think the problem 
has to do with that large item being allocated /on the stack/. If I'm 
remembering correctly, your compiler manual will tell you how to change 
the default size of the stack (which is normally quite small).

You may also want to consider putting that array outside of the stack, 
either as a static global or a dynamically allocated value (on the heap). 
Each solution has its advantages, depending on what you're doing.

  Bob
Re: MS C Compiler bug
#7879
Author: Bob Stout
Date: Wed, 08 Nov 1995 03:55
37 lines
1854 bytes
On 7 Nov 1995, Eric Prebys wrote:

> We are compiling software on a 486 using the Microsoft C compiler,
> version 7.0.  The following program
> 
> =========================================================
> int main(int, char **);
> 
> int main(int argc, char **argv)
> {
> float aaabbb[2][500];
> exit(0);
> }
> ==========================================================
> 
> compiles, but causes the error
> 
> R6000 - stack overflow
> 
> when run.  The problem goes away if the array is made smaller, but
> this array shouldn't cause any problems.

Of course it should cause problems! Your aaabbb is an auto array of
2*500*4 bytes (sizeof(float) = 4), or 4K. The default stack size for MSC 
7 is 2K. Similarly, the solution is also in your docs - recompile it 
using the /F xxxx option where xxxx is the stack size in hex. Since the 
default is 2K and you want to add another 4K, you should start out trying 
/F 1800.

-------------------------------------------------------------
MicroFirm: Down to the C in chips...
FidoNet 1:106/2000.6
Internet bobstout@neosoft.com
Home of SNIPPETS - Current release:
      ftp.brokersys.com:/pub/snippets/snip9510.zip & snip9510.taz (.tar.Z)
      juge.com:/c/file/c/snip9510.lzh
      ftp.Coast.NET:/SimTel/msdos/c/snip9510.zip (& SimTel mirrors)
Re: MS C Compiler bug
#7876
Author: John R Buchan (jatmon)
Date: Wed, 08 Nov 1995 04:42
36 lines
1730 bytes
In article <47oaiq$b02@cnn.Princeton.EDU>, prebys@puhep1.princeton.edu says...
>
>
>We are compiling software on a 486 using the Microsoft C compiler,
>version 7.0.  The following program
>
>=========================================================
>int main(int, char **);
>
>int main(int argc, char **argv)
>{
>float aaabbb[2][500];
>exit(0);
>}
>==========================================================
>
>compiles, but causes the error
>
>R6000 - stack overflow
>
>when run.  The problem goes away if the array is made smaller, but
>this array shouldn't cause any problems.  Does anyone have any 
>suggestions?  The problem is independent of which memory model
>I use or whether or not I try to initialize the array (or
>any other switch or operation I can think of).

Assuming sizeof(float) == 4, you array definition is pushing 4000 bytes 
on the stack.  This apparently exceeds your stack size.  The simplest 
solution is to make the array static.  Either use the static storage 
specifier or move the definition outside of main to make it global. You
could, alternatively, use a dynamic array or look through your compiler's
docs for a method to change the stack size.

-- 
John R Buchan           -:|:-     Looking for that elusive FAQ?  ftp to:
jatmon@mail.iag.net     -:|:-     rtfm.mit.edu /pub/usenet-by-group/....
Re: MS C Compiler bug
#7880
Author: W. Paul Mills
Date: Wed, 08 Nov 1995 14:42
38 lines
1597 bytes
Eric Prebys <prebys@puhep1.princeton.edu> writes:


>We are compiling software on a 486 using the Microsoft C compiler,
>version 7.0.  The following program

>=========================================================
>int main(int, char **);

>int main(int argc, char **argv)
>{
>float aaabbb[2][500];
>exit(0);
>}
>==========================================================

>compiles, but causes the error

>R6000 - stack overflow

>when run.  The problem goes away if the array is made smaller, but
>this array shouldn't cause any problems.  Does anyone have any 
>suggestions?  The problem is independent of which memory model
>I use or whether or not I try to initialize the array (or
>any other switch or operation I can think of).

This is not a bug!

You need to increase the size of your stack. A command line option
will do that for you.

You could also declare your array outside of main, which would
take less stack space.

-- 
| ------------------ |  New LINUX Hacker | My only love is my |
| wpmills@tyrell.net |-------------------| computer. No other |
| -----------------  |    Old C Hacker   |    is worth it!    |
Re: MS C Compiler bug
#7882
Author: Vic Kulikauskas
Date: Fri, 10 Nov 1995 00:10
32 lines
1494 bytes
Eric Prebys <prebys@puhep1.princeton.edu> writes:

> We are compiling software on a 486 using the Microsoft C compiler,
> version 7.0.  The following program
>
> =========================================================
> int main(int, char **);
>
> int main(int argc, char **argv)
> {
> float aaabbb[2][500];
> exit(0);
> }
> ==========================================================
>
> compiles, but causes the error
>
> R6000 - stack overflow
>
> when run.  The problem goes away if the array is made smaller, but
> this array shouldn't cause any problems.  Does anyone have any 
> suggestions?  The problem is independent of which memory model
> I use or whether or not I try to initialize the array (or
> any other switch or operation I can think of).

Your array uses about 4K of stack.  What stack size have you allocated?  
The default value is 2K, or at least it is with MSC 6.0, so of course 
you would get a stack overflow unless you changed the default.  You can 
change the stack size by using the /F option to CL, or the /STACK option 
to LINK.

Vic
Re: MS C Compiler bug
#7881
Author: Ricky LUI
Date: Fri, 10 Nov 1995 00:38
26 lines
1053 bytes
<47oaiq$b02@cnn.Princeton.EDU>
prebys@puhep1.princeton.edu

>> =========================================================
>> int main(int, char **);
>> 
>> int main(int argc, char **argv)
>> {
>> float aaabbb[2][500];
>> exit(0);
>> }
>> ==========================================================
>> 
>> compiles, but causes the error
>> 
>> R6000 - stack overflow

I use Microsoft C/C++ Ver7.0, and I had to use a char[512][512] array.
The only way I can get around this problem is to declare the variable
as: 
  
static char my_array[512][512]

Hope this helps

Ricky
Re: MS C Compiler bug
#7883
Author: Jean-Luc Lachance
Date: Tue, 14 Nov 1995 16:19
36 lines
1579 bytes
In article <951109.191029.2O2.rnr.w164w@mmalt.guild.org> vic@mmalt.guild.org (Vic Kulikauskas) writes:
>Eric Prebys <prebys@puhep1.princeton.edu> writes:

>> We are compiling software on a 486 using the Microsoft C compiler,
>> version 7.0.  The following program
>>
>> =========================================================
>> int main(int, char **);
>>
>> int main(int argc, char **argv)
>> {
>> float aaabbb[2][500];
>> exit(0);
>> }
>> ==========================================================
>>
>> compiles, but causes the error
>>
>> R6000 - stack overflow
>>
>Your array uses about 4K of stack.  What stack size have you allocated?  
>The default value is 2K, or at least it is with MSC 6.0, so of course 
>you would get a stack overflow unless you changed the default.  You can 
>change the stack size by using the /F option to CL, or the /STACK option 
>to LINK.

Better yet, declare aaabbb as static.



--
Jean-Luc Lachance                   | jllachan@interLink.net
Action Telematique Inc              | (514)386-5396
5500, pl. de Jumonville, suite 312
Montreal, QC, CANADA
H1M 3L8
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