[bf1942] Failure to open ports

ScratchMonkey ScratchMonkey at SewingWitch.com
Fri Jan 3 07:47:32 EST 2003


--On Friday, January 03, 2003 4:12 AM -0800 ScratchMonkey 
<ScratchMonkey at sewingwitch.com> wrote:

> I'm trying to trace through it. pthread_create is a library routine that
> maps into a bunch of system calls, and strace shows the underlying calls
> like clone() and various signal things (I think that's the rt* stuff).

Found it!

The only errno value indicated for pthread_create is EAGAIN, which 
indicates some kind of resource shortage. So I logged "ulimit -a" in both 
cases. In the successful case (from the command line restart), "ulimit -s" 
(stack size) is 2040k, while the failing case reports 2097151k (0x7fffffff, 
AKA INT_MAX). So I explicitly set "ulimit -s 2040" in my mortal's startup 
script before spawning the server and it successfully spawns the thread.

My guess is that pthread_create attempts to allocate a stack of the size 
specified by ulimit and fails.

Since this is a memory-intensive app, I'd recommend using pthread 
attributes to explicitly set the stack size to what you know you need. (Are 
there any static analysis tools for Linux that will report the stack usage 
of a program given just the binary or the set of sources?) Meanwhile, let 
us know what value we should be using for the stack size and we can just 
plug in a ulimit call in our scripts.



More information about the Bf1942 mailing list