From owner-freebsd-hackers@FreeBSD.ORG Mon May 26 06:20:46 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0A61337B401; Mon, 26 May 2003 06:20:46 -0700 (PDT) Received: from posgate.acis.com.au (posgate.acis.com.au [203.14.230.14]) by mx1.FreeBSD.org (Postfix) with ESMTP id 525EC43F75; Mon, 26 May 2003 06:20:44 -0700 (PDT) (envelope-from andymac@bullseye.apana.org.au) Received: from bullseye.apana.org.au (dialup-1.acis.com.au [203.14.230.80] (may be forged)) by posgate.acis.com.au (8.12.7/8.12.7) with ESMTP id h4QDKVGk010666; Mon, 26 May 2003 23:20:33 +1000 Received: from bullseye.apana.org.au (localhost.apana.org.au [127.0.0.1]) h4QBH019058728; Mon, 26 May 2003 21:17:00 +1000 (EST) (envelope-from andymac@bullseye.apana.org.au) Received: from localhost (andymac@localhost)h4QBH0B5058725; Mon, 26 May 2003 21:17:00 +1000 (EST) (envelope-from andymac@bullseye.apana.org.au) Date: Mon, 26 May 2003 21:17:00 +1000 (EST) From: Andrew MacIntyre To: Daniel Eischen In-Reply-To: Message-ID: <20030526204036.D58689@bullseye.apana.org.au> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.30 (www . roaringpenguin . com / mimedefang) cc: freebsd-hackers@freebsd.org cc: alane@freebsd.org Subject: Re: setting stacksize in "initial" thread (pthreads, 4.8R) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 May 2003 13:20:46 -0000 On Sun, 25 May 2003, Daniel Eischen wrote: > On Mon, 26 May 2003, Andrew MacIntyre wrote: > > > The problem actually occurs with recursive matches in Python's regex > > engine. Python has a hardcoded regex recursion limit, which has trapped > > ballistic matches before running out of the default stack. However a > > couple of recent fixes to the regex engine have increased stack > > consumption, and the hard limit has to be lowered. > > How do you know it is the main thread stack and not a different > thread stack that is getting exceeded? By default, threads > other than main get a 64K stack, and this is totally configurable > by the application. Activating threads in Python requires importing either of the threads support modules (theres a high level module & a low level module). The regex regression test doesn't import either threads module. Neither module supports setting the thread stack size from Python code. Python by default uses the system's default thread stack size, but this can be overridden at compile time. I've tried bumping the thread stack size up from the default to 1MB with no effect. Also, the recursive routine takes 3 arguments (2 pointers + 1 int, ie 12 bytes), and has at least 36 bytes worth of local variables. Failing with ~8100 levels of recursion means a minimum of ~380kB of stack consumption, not including overhead (frame pointer, registers pushed to the stack, etc), ie lots more than the default thread stack size. The routine in question can easily support a stack exhaustion check on each iteration, rather than relying on hard coded limits. Its just a matter of knowing how to do the check, and how expensive it is. Even moderately expensive could be more attactive than tempting bus errors. Regards, Andrew. -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andymac@bullseye.apana.org.au (pref) | Snail: PO Box 370 andymac@pcug.org.au (alt) | Belconnen ACT 2616 Web: http://www.andymac.org/ | Australia