Subject: Native threads: "Not enough stacks" error?
To: None <port-alpha@netbsd.org>
From: Paul Mather <paul@gromit.dlib.vt.edu>
List: port-alpha
Date: 11/27/2003 22:18:57
Yesterday I found a large cluster of "Not enough stacks" messages
(~150, all told) in my logs after running BitTorrent for a little
while.  (BitTorrent was a fresh install via /usr/pkgsrc/net/bittorrent
and I'm using a version of Python from /usr/pkgsrc/lang/python23-pth.)

I was running btdownloadcurses.py, and all was going well for a couple
of minutes.  Then, my system basically went out to lunch for several
minutes.  Just when I thought it had crashed, it sprang back to life
as btdownloadcurses.py core dumped.

Amusingly (or perhaps surprisingly), "top" run shortly afterwards
showed a load average of ~15, and---get this---a 5-minute load average
of almost 600!!  That's the highest load average I can ever remember
seeing on any system I've used. :-)

Later, I discovered the following in my logs (abbreviated, to save
space):

>>>>>
Nov 26 18:16:26 chumby /netbsd: sa_switch(13870.16 flag 4900004): Not enough stacks.
Nov 26 18:19:09 chumby /netbsd: g 4900004): Not enough stacks.
Nov 26 18:19:09 chumby /netbsd: sa_switch(13870.1720 flag 4900004): Not enough stacks.
Nov 26 18:19:09 chumby /netbsd: sa_switch(13870.1721 flag 4900004): Not enough stacks.
Nov 26 18:19:09 chumby /netbsd: sa_switch(13870.1722 flag 4900004): Not enough stacks.
Nov 26 18:19:10 chumby /netbsd: sa_switch(13870.1723 flag 4900004): Not enough stacks.
Nov 26 18:19:10 chumby /netbsd: sa_switch(13870.1724 flag 4900004): Not enough stacks.
[[..]]
Nov 26 18:19:15 chumby /netbsd: sa_switch(13870.1783 flag 4900004): Not enough stacks.
Nov 26 18:19:15 chumby /netbsd: sa_switch(13870.1784 flag 4900004): Not enough stacks.
Nov 26 18:19:15 chumby /netbsd: sa_switch(13870.1785): no cached LWP for upcall.
Nov 26 18:19:16 chumby /netbsd: sa_switch(13870.1785 flag 4900004): Not enough stacks.
Nov 26 18:19:16 chumby /netbsd: sa_switch(13870.1786 flag 4900004): Not enough stacks.
Nov 26 18:19:16 chumby /netbsd: sa_switch(13870.1787 flag 4900004): Not enough stacks.
[[..]]
Nov 26 18:19:26 chumby /netbsd: sa_switch(13870.1860 flag 4900004): Not enough stacks.
Nov 26 18:19:27 chumby /netbsd: sa_switch(13870.1861 flag 4900004): Not enough stacks.
Nov 26 18:19:27 chumby /netbsd: sa_switch(13870.1862 flag 4900004): Not enough stacks.
Nov 26 18:19:27 chumby /netbsd: sa_switch(13870.1863 flag 4900004): Not enough stacks.
Nov 26 18:19:27 chumby /netbsd: sa_switch(13870.1864 flag 4900004): Not enough stacks.
Nov 26 18:19:28 chumby /netbsd: sa_switch(13870.1865 flag 4900004): Not enough stacks.
Nov 26 18:19:28 chumby /netbsd: sa_switch(13870.1866): no cached LWP for upcall.
<<<<<

Does anyone know if BitTorrent does this on other NetBSD platforms, or
are native threads on alpha the problem here?  (I only have NetBSD
installed on alpha, so I can't test for myself.  I do use BitTorrent
on FreeBSD/i386 without any problems, though.)

Are there any resource limits that can be put on native thread usage,
to prevent this kind of excessive resource starvation?

Cheers,

Paul.

e-mail: paul@gromit.dlib.vt.edu

"Without music to decorate it, time is just a bunch of boring production
 deadlines or dates by which bills must be paid."
        --- Frank Vincent Zappa