 |
|
 |
|
Next: Help with SAFARI problems/ IE too!
|
| Author |
Message |
External

Since: Jul 23, 2003 Posts: 2
|
(Msg. 1) Posted: Thu Jul 24, 2003 2:26 am
Post subject: MacOS X small stack? Archived from groups: comp>sys>mac>programmer>misc (more info?)
|
|
|
ok, perhaps i'm just being an idiot, but can someone tell me why this
doesn't work?
int main ( int argc, char **argv )
{
int foo[160000];
return 1;
}
It crashes when i try to run it (the crash log is at the bottom of the
message). I'm running on 10.2.6, this executable was created using
gcc but the same problem exists when i use project builder.
It looks like i'm running out of stack space, but all things
considered, this isn't *that* much memory that i'm try to allocate on
the stack...is it?
Here's some info from gcc and uname:
fiorina161% gcc -v
Reading specs from /usr/libexec/gcc/darwin/ppc/3.1/specs
Thread model: posix
Apple Computer, Inc. GCC version 1175, based on gcc version 3.1
20020420 (prerelease)
fiorina161% uname -a
Darwin fiorina161.nowhere.com 6.6 Darwin Kernel Version 6.6: Thu May
1 21:48:54 PDT 2003; root:xnu/xnu-344.34.obj~1/RELEASE_PPC Power
Macintosh powerpc
Here's the crash log:
Date/Time: 2003-07-23 18:43:45 -0700
OS Version: 10.2.6 (Build 6L60)
Host: fiorina161.nowhere.com
Command: a.out
PID: 2053
Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_INVALID_ADDRESS (0x0001) at 0xbff63490
Thread 0 Crashed:
#0 0x00001d5c in main
#1 0x00001af4 in _start (crt.c:267)
#2 0x00001974 in start
PPC Thread State:
srr0: 0x00001d5c srr1: 0x0000d030 vrsave: 0x00000000
xer: 0x00000000 lr: 0x00001af4 ctr: 0x9000a5a0 mq: 0x00000000
r0: 0xfff63bb0 r1: 0xbffff8e0 r2: 0x00000000 r3: 0x00000001
r4: 0xbffff994 r5: 0xbffff99c r6: 0xbffffa48 r7: 0x8fe48550
r8: 0xbffffa59 r9: 0x0000198c r10: 0x00000007 r11: 0xbffffa58
r12: 0x9000a5a0 r13: 0x00000000 r14: 0x00000000 r15: 0x00000000
r16: 0x00000000 r17: 0x00000000 r18: 0x00000000 r19: 0x00000000
r20: 0x00000000 r21: 0x00000000 r22: 0x00000000 r23: 0x00000000
r24: 0x00000000 r25: 0x00000000 r26: 0xbffff990 r27: 0x00000008
r28: 0x00000001 r29: 0xbffff99c r30: 0xbffff994 r31: 0x0000198c
Thank you.
--tka >> Stay informed about: MacOS X small stack? |
|
| Back to top |
|
 |  |
External

Since: Jun 28, 2003 Posts: 99
|
(Msg. 2) Posted: Thu Jul 24, 2003 1:12 pm
Post subject: Re: MacOS X small stack? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article <7c0c6162.0307232226.1e4d1296 DeleteThis @posting.google.com>,
tka2 DeleteThis @mail.com (Todd Aceman) wrote:
> ok, perhaps i'm just being an idiot, but can someone tell me why this
> doesn't work?
>
> int main ( int argc, char **argv )
> {
> int foo[160000];
> return 1;
> }
>
> It crashes when i try to run it (the crash log is at the bottom of the
> message). I'm running on 10.2.6, this executable was created using
> gcc but the same problem exists when i use project builder.
>
> It looks like i'm running out of stack space, but all things
> considered, this isn't *that* much memory that i'm try to allocate on
> the stack...is it?
The default stack size is 512KB, but you're trying to use more than that.
You can compile with a larger stack size by passing the -stack_size flag
to the linker. See ld's man page for details. To pass a linker flag
through from the compiler, use the -Wl flag to gcc. In other words,
compile like this:
gcc -Wl,-stack_size -Wl,<some multiple of 4K> -o foo foo.c
Hope this helps,
Eric
--
Eric Albert ejalbert DeleteThis @stanford.edu
<a style='text-decoration: underline;' href="http://rescomp.stanford.edu/~ejalbert/" target="_blank">http://rescomp.stanford.edu/~ejalbert/</a><!-- ~MESSAGE_AFTER~ --> >> Stay informed about: MacOS X small stack? |
|
| Back to top |
|
 |  |
External

Since: Aug 11, 2003 Posts: 4
|
(Msg. 3) Posted: Thu Jul 24, 2003 3:48 pm
Post subject: Re: MacOS X small stack? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
well,
i'm afraid it just makes problems to have "large" stack variables
under Mac OS; I had the same problem when porting windows
applications. I think you can adjust the stacksize in the compiler
settings somewhere but its not recommended afaik
Peter >> Stay informed about: MacOS X small stack? |
|
| Back to top |
|
 |  |
External

Since: Jun 25, 2003 Posts: 346
|
(Msg. 4) Posted: Thu Jul 24, 2003 4:49 pm
Post subject: Re: MacOS X small stack? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On 23 Jul 2003 23:26:51 -0700, Todd Aceman wrote:
> ok, perhaps i'm just being an idiot, but can someone tell me why this
> doesn't work?
> int main ( int argc, char **argv )
> {
> int foo[160000];
> return 1;
> }
> It crashes when i try to run it (the crash log is at the bottom of the
> message). I'm running on 10.2.6, this executable was created using
> gcc but the same problem exists when i use project builder.
> It looks like i'm running out of stack space, but all things
> considered, this isn't *that* much memory that i'm try to allocate on
> the stack...is it?
You are trying to allocate 160000*sizeof(int) bytes on the stack. This
is because foo is declared inside function main and is (by default)
automatic. If you declare it globally, or if you make it static, the
problem should not arise.
The 640000 bytes probably exceeds your default stacksize limit, but you
can change it. If your shell is the default tcsh, type "limit" to see
what all your limits are. You can set your stacksize limit using a
command like
limit stacksize <nnnnn>
or
limit stacksize unlimited
where <nnnnnn> is the desired limit in kbytes. I set mine to 16384
kbytes at login time with an appropriate entry in my shell startup file.
If you use bash, as I do, then the commands are
ulimit -a
to view the limits, and
ulimit -s <nnnnn>
or
ulimit -s unlimited
to set the stacksize.
--
Dave Seaman
Judge Yohn's mistakes revealed in Mumia Abu-Jamal ruling.
<http://www.commoncouragepress.com/index.cfm?action=book&bookid=228><!-- ~MESSAGE_AFTER~ --> >> Stay informed about: MacOS X small stack? |
|
| Back to top |
|
 |  |
External

Since: Jul 23, 2003 Posts: 2
|
(Msg. 5) Posted: Fri Jul 25, 2003 3:32 am
Post subject: Re: MacOS X small stack? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Thanks to everyone who answered. normally, i'd allocate this kind of
stuff on the heap, but i was being lazy. :)
Thanks again.
--tka
Eric Albert <ejalbert.RemoveThis@stanford.edu> wrote in message news:<ejalbert-15C896.10124524072003.RemoveThis@news.stanford.edu>...
> In article <7c0c6162.0307232226.1e4d1296.RemoveThis@posting.google.com>,
> tka2.RemoveThis@mail.com (Todd Aceman) wrote:
>
> > ok, perhaps i'm just being an idiot, but can someone tell me why this
> > doesn't work?
> >
> > int main ( int argc, char **argv )
> > {
> > int foo[160000];
> > return 1;
> > }
> >
> > It crashes when i try to run it (the crash log is at the bottom of the
> > message). I'm running on 10.2.6, this executable was created using
> > gcc but the same problem exists when i use project builder.
> >
> > It looks like i'm running out of stack space, but all things
> > considered, this isn't *that* much memory that i'm try to allocate on
> > the stack...is it?
>
> The default stack size is 512KB, but you're trying to use more than that.
>
> You can compile with a larger stack size by passing the -stack_size flag
> to the linker. See ld's man page for details. To pass a linker flag
> through from the compiler, use the -Wl flag to gcc. In other words,
> compile like this:
> gcc -Wl,-stack_size -Wl,<some multiple of 4K> -o foo foo.c
>
> Hope this helps,
> Eric<!-- ~MESSAGE_AFTER~ --> >> Stay informed about: MacOS X small stack? |
|
| Back to top |
|
 |  |
External

Since: Oct 10, 2003 Posts: 152
|
(Msg. 6) Posted: Sun Jul 27, 2003 2:45 am
Post subject: Re: MacOS X small stack? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article <7c0c6162.0307232226.1e4d1296.DeleteThis@posting.google.com>,
tka2.DeleteThis@mail.com (Todd Aceman) wrote:
> int foo[160000];
You should probably get an error message rather than a crash,
but you're abusing stack space for something that should be
stored in non-stack memory. C will happily let you compile
that program but it's not really good programming style.<!-- ~MESSAGE_AFTER~ --> >> Stay informed about: MacOS X small stack? |
|
| Back to top |
|
 |  |
| Related Topics: | Does Mac OS 9/8 have an IrDA stack? - hi, 1. Does Mac OS 9/8 support an IrDA stack, If yes does it support any devices 2. Is there any difference in the IOKit architecture of MacOS10.2 and 10.3 Please give me some information about this. chandra sekhar
Small C IDE for students - Is there a small library with turtlegraphics for gcc under Tiger ? Preferably with a popup graphic window. Thanks a lot, JG
Antialiasing small fonts? - I'm still stumped...I'm trying to draw small fonts smoothly--fonts smaller than specified in System Preferences. I have a general purpose text drawing routine that can draw QD or Quartz text, antialiased or aliased, but nothing looks very good at..
MacOS X, X11 and GLX - Hello. I'm not sure, if I selected this group correctly. I have some code, which uses X11 and GLX/OpenGL. Unfortunatly, I cannot rewrite it using MacOS X native API, so, I have to use MacOS X's X11 application. In my programm I: 1) select specific..
.Net od Mono under MacOS X? - Hi, I'm just new to Mac and I would like to do my first progrmming steps on the Mac. Is there something like .Net or Mono existing for The Mac OS X Platform? Greetings Christoph |
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum
|
|
|
|
 |
|
|