[Zope] finding the reason why my Zope crashes (FreeBSD thread stack size)

Reinoud van Leeuwen reinoud.v@n.leeuwen.net
Wed, 9 Oct 2002 16:43:03 +0200


On Tue, Oct 08, 2002 at 04:05:30PM +0200, Reinoud van Leeuwen wrote:
> Hi,
> 
> I have some trouble with my zope test server. I am trying to decide
> whether to use Silva or Plone, but with both products, my Zope site
> crashes reproduceable. (in both products while adding a site).
> 
> I use
> Zope Version  (Zope 2.5.1 (source release, python 2.1, linux2), python
> 2.1.3, freebsd4)
> Python Version  2.1.3 (#2, Oct 1 2002, 17:24:12) [GCC 2.95.3 20010315
> (release) [FreeBSD]]
> System Platform  freebsd4
> SOFTWARE_HOME  /usr/local/zope/zope/lib/python
> 
> On FreeBSD 4.5 RELEASE.

Found it (thanx Thomas)! It was caused by the FreeBSD thread stack size 
problem. Since not all descriptions on the web are too clear about it, I 
will describe how to fix it here as well 
(note: this is only neccessary if you build Python on FreeBSD by hand. I 
think the version from the ports has a fix)

after downloading and unpacking the Python source (2.1.3), run 
./configure --prefix=/usr

change the file Python/thread_pthread.h. Here is a diff from the original:

*** 128,144 ****
  {
        pthread_t th;
        int success;
  #ifdef PTHREAD_SYSTEM_SCHED_SUPPORTED
        pthread_attr_t attrs;
  #endif
          dprintf(("PyThread_start_new_thread called\n"));
        if (!initialized)
                PyThread_init_thread();
  #ifdef PTHREAD_SYSTEM_SCHED_SUPPORTED
        pthread_attr_init(&attrs);
        pthread_attr_setscope(&attrs, PTHREAD_SCOPE_SYSTEM);
  #endif
-
        success = pthread_create(&th,
  #if defined(PY_PTHREAD_D4)
                                 pthread_attr_default,
--- 128,147 ----
  {
        pthread_t th;
        int success;
+         pthread_attr_t pta;
  #ifdef PTHREAD_SYSTEM_SCHED_SUPPORTED
        pthread_attr_t attrs;
  #endif
+         pthread_attr_init(&pta);
+         pthread_attr_setstacksize(&pta, (1<<17));
          dprintf(("PyThread_start_new_thread called\n"));
        if (!initialized)
                PyThread_init_thread();
  #ifdef PTHREAD_SYSTEM_SCHED_SUPPORTED
        pthread_attr_init(&attrs);
        pthread_attr_setscope(&attrs, PTHREAD_SCOPE_SYSTEM);
+       pthread_attr_setstacksize(&attrs, (1<<17));
  #endif
        success = pthread_create(&th,
  #if defined(PY_PTHREAD_D4)
                                 pthread_attr_default,
***************

(the new version is the bottom one!)

-- 
__________________________________________________
"Nothing is as subjective as reality"
Reinoud van Leeuwen    reinoud.v@n.leeuwen.net
http://www.xs4all.nl/~reinoud
__________________________________________________