[Zope-dev] FreeBSD, Zope, and Python 2.1

Matthew T. Kromer matt@zope.com
Fri, 04 Jan 2002 16:47:00 -0500

For what it's worth:

Today I helped Jens track down a problem under FreeBSD where Zope was 
crashing rendering a page which rendered successfully on other systems. 
 It turns out that the default stack size for a thread under FreeBSD is 
64K, and that's not enough stack space to render this particular page of 
his (a Tracker page) -- most likely due to changes with how the 
RestrictedPython compiler is used/invoked by DTML processing, since this 
represents a big change from Zope 2.3.

The solution we used was modifying Python/thread_pthread.h and the 
PyThread_start_new_thread function; specifically, instead of using a 
(pthread_attr_t *) NULL, we made a new attribute instead:

pthread_attr_t pta;


pthread_attr_setstacksize(&pta, (1<<17));

and using &pta in the thread creation function rather than NULL.

Recompiling Python 2.1 with changes gives it a 128K stack per thread, 
which seemed sufficient to render the Tracker page in question.

Does anyone know of a better way to tune thread stack sizes on FreeBSD?