Ask a Question related to UNIX Programming, Design and Development.
-
A. W. Dunstan #1
Re: Too much on the stack?
Michael B Allen wrote:
The pthreads I've used (RH 7.3, glibc 2.2.5) allocated a separate 2MB stack> On Sat, 21 Jun 2003 13:05:15 -0400, Paul Pluzhnikov wrote:
>>>>>>> Why doesn't the following program overrun the stack?
>> Why should it? Your 'ulimit' is apparently set higher than 6.5M ... The
>> only reason for this program to run out of stack is if it exceeds stack
>> ulimit, or comes close to where shared libraries are mapped. The 'ulimit
>> -s' is quite often unlimited, and shared libraries on Linux are usually
>> mapped up from 0x40000000.
> Interesting! I didn't know this. Ulimit is indeed set to 'unlimited'.
>>>> If you do not have gazillion of very large shared libraries, their
>> mappings are quite likely to stay below 0x50000000, which gives your
>> program quite a few more megabytes to grow.
>>>>>>> How much is too much on the stack?
>> That depends on your OS, and whether you ever plan to use your code in
>> multi-threaded environment, where stack sizes are significantly more
>> limited (Linux default is 8MB IIRC).
> The code is actually using pthreads. A thread will be calling this
> function.
>
space for each thread. If you set your ulimit stack space to unlimited you
might have threads stepping on each other's stack.
--
Al Dunstan, Software Engineer
OptiMetrics, Inc.
3115 Professional Drive
Ann Arbor, MI 48104-5131
"To educate a man in mind and not in morals is to
educate a menace to society."
- Theodore Roosevelt
A. W. Dunstan Guest
-
Stack Overflow Error - Need Help!
We have a server on which we are running CF MX 7 Enterprise. It is a Windows 2000 Server (service pack 4). It is talking to a SQL Server 2000... -
get the Java stack trace
hi, is there a way to get the full java stack trace when an exception is occured? May be a cfcatch or cferror variable that contains this stack? Do... -
Out of stack space
Hello, I'm using iis 5 on windows 2000 Pro. I have a recursive function. If the recursion is too big, I get a "Out of stack space" error. On a... -
GC and the stack
Hello, As far as I understand the ruby gc will not collect objects that are referenced from the stack, ie the "C/native" stack in a ruby... -
Ruby GC eating my VALUE on the stack
I thought I had read everything I needed about the Ruby GC, but something just popped up that took me by surprise. I am allocating a structure... -
Paul Pluzhnikov #2
Re: Too much on the stack?
"A. W. Dunstan" <readHere@post.here> writes:
You are correct on this point.> The pthreads I've used (RH 7.3, glibc 2.2.5) allocated a separate 2MB stack
> space for each thread.
But quite mistaken on that one, for 2 reasons:> If you set your ulimit stack space to unlimited you
> might have threads stepping on each other's stack.
- 'ulimit -s' has *absolutely nothing* to with sizes of thread
stacks, and
- the thread manager puts a guard page (mprotect()ed with no access)
at the end of each 2MB stack region, so before a thread can
"step on other's stack", it will crash accessing the guard page.
That's not to say that a thread can't trash other thread's stack
due to a bad pointer ... But 'ulimit -s' has nothing to do with this.
Cheers,
--
In order to understand recursion you must first understand recursion.
Paul Pluzhnikov Guest
-
Chris Torek #3
Re: Too much on the stack?
In article <uhe6ej0za.fsfYB8X@earthlink.net>
Paul Pluzhnikov <ppluzhnikov@earthlink.net> writes:Unless, of course, you skip right over the guard page.>- the thread manager puts a guard page (mprotect()ed with no access)
> at the end of each 2MB stack region, so before a thread can
> "step on other's stack", it will crash accessing the guard page.
If the page size is 4096 bytes and you allocate at least 8192
bytes (via "sub $8192,sp" or equivalent), you have a good chance
of doing just that.
--
In-Real-Life: Chris Torek, Wind River Systems (BSD engineering)
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it [url]http://67.40.109.61/torek/index.html[/url] (for the moment)
Reading email is like searching for food in the garbage, thanks to spammers.
Chris Torek Guest
-
Cliff Fu Xuan Chen #4
Search for stream program
Hi All,
I'm a green hand on stream programming.
Does someone give me some good links or easy example on this?
Thanks in advance!
Cliff
Cliff Fu Xuan Chen Guest
-
Cliff Fu Xuan Chen #5
Search for stream program
Hi All,
I'm a green hand on stream programming.
Does someone give me some good links or easy example on this?
Thanks in advance!
Cliff
Cliff Fu Xuan Chen Guest
-
Andrew Gabriel #6
Re: Search for stream program
In article <3F02AC70.8F1145B9@lucent.com>,
Cliff Fu Xuan Chen <fchen7@lucent.com> writes:You don't say which UNIX, but if it's Solaris, then look at Sun's>
> Hi All,
>
> I'm a green hand on stream programming.
>
> Does someone give me some good links or easy example on this?
STREAMS Programming Manual, [url]http://docs.sun.com/db/doc/806-6546[/url]
Much of this will be relevant to non-Solaris UNIXs with STREAMS
too, but the module loading and multi-threaded kernel parts will
be Solaris-specific.
PS, please turn off the HTML posting.
--
Andrew Gabriel
Consultant Software Engineer
Andrew Gabriel Guest



Reply With Quote

