The following patch to Python/thread_pthread.h should fix the FreeBSD? python crashing problem discussed on #226 on freebsd, python/zope may crash repeatably when browsing diffs or saving certain pages. This fix is automatically applied if you installed Python 2.1.3 using the ports after Feb 2003. Using a recent version of the FreeBSD? ports is much better than manually trying to use these patches.

To install a new Python 2.1.3 on FreeBSD?, do the following:

You can find instructions on how to install the FreeBSD? ports collection in the FreeBSD? Handbook, Chapter 4.5 Using the Ports Collection:

http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports-using.html

You might also want to check that the python21 port you're building is Python 2.1.3. To verify this, look at the PORTVERSION line in /usr/ports/lang/python21/Makefile. If it isn't 2.1.3, you should update your ports collection via cvsup or this page. Instructions are in the Handbook chapter I referenced above. Note that the ports collection is about 15Mb. You can also only download /usr/ports/langs/python21 (4.0 stable).
The port will automatically fetch Python 2.1.3 from the Python website


Remarks


If you really want to patch Python 2.1.3 by hand, use the following information

  *** /usr/ports/distfiles/python/Python-2.1.3/Python/thread_pthread.h  Thu Jan 10 03:12:20 2002
  --- work/Python-2.1.3/Python/thread_pthread.h Thu Oct 17 21:59:48 2002
  ***************
  *** 128,141 ****
    {
        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

  --- 128,141 ----
    {
        pthread_t th;
        int success;
        pthread_attr_t attrs;
  ! 
            dprintf(("PyThread_start_new_thread called\n"));
        if (!initialized)
                PyThread_init_thread();
        pthread_attr_init(&attrs);
  +     pthread_attr_setstacksize (&attrs, (1<<17));
  + #ifdef PTHREAD_SYSTEM_SCHED_SUPPORTED
        pthread_attr_setscope(&attrs, PTHREAD_SCOPE_SYSTEM);
    #endif

  ***************
  *** 153,163 ****
                                 func,
                                 arg
    #elif defined(PY_PTHREAD_STD)
  - #ifdef PTHREAD_SYSTEM_SCHED_SUPPORTED
                                 &attrs,
  - #else
  -                              (pthread_attr_t*)NULL,
  - #endif
                                 (void* (*)(void *))func,
                                 (void *)arg
    #endif
  --- 153,159 ----

To manually apply this patch

If you have trouble with using patch you can also download a patched thread_pthread.h

Thanks.. I did have trouble. After pasting the patch from this page into a file, I wonder why I got this :

 su-2.05# cd /usr/ports/lang/python21
 su-2.05# patch <python-stack-size.patch 
 Hmm...  Looks like a new-style context diff to me...
 (Patch is indented 2 spaces.)
 The text leading up to this was:
 --------------------------
 |  *** /usr/ports/distfiles/python/Python-2.1.3/Python/thread_pthread.h  Thu Jan 10 03:12:20 2002
 |  --- work/Python-2.1.3/Python/thread_pthread.h Thu Oct 17 21:59:48 2002
 --------------------------
 Patching file work/Python-2.1.3/Python/thread_pthread.h using Plan A...
 Hunk #1 failed at 128.
 Hunk #2 failed at 153.
 2 out of 2 hunks failed--saving rejects to work/Python-2.1.3/Python/thread_pthread.h.rej
 done

Or, if you want to test before overwriting your existing python, use

PageMaintainers: BobFinch, PieterB


I just e-mailed the maintainer of the FreeBSD? port. I hope it will be installed as default, because that would make Zope/Zwiki life much easier. -- PieterB

PieterB, 2003/03/29 20:17 GMT
This patch is applied to the FreeBSD? ports-tree later than: Thu Feb 6 11:27:49 2003.

Check if you have /usr/ports/lang/python21/files/patch-Python-thread_pthread.h-stacksize

-- PieterB


comments:

New input... --PieterB, 2003/06/21 21:35 GMT reply
Found article: How to Get Python 2.1.3, FreeBSD? and Plone to Happily Coexist (old, same kind of article, but nicer layout ;).

Also some new input on this comp.python.general thread (mostly based on patches for Python 2.2 and Python 2.3)

Wow, this should fix it... --PieterB, 2003/06/22 07:43 GMT reply
Ok, gmane has no way to browse a thread (stupid). See groups.google.com thread on "Python 2.2.3 test_re.py fails with coredump on FreeBSD? 5.0, fails also on FreeBSD4?.8" instead. It mentions SF[ 740234 ]? test/build-failures on FreeBSD? stable/current.

Longterm options to fix this problem seem to be:

Yikes --SimonMichael, 2003/06/22 11:57 GMT reply
This seems to be getting still more complicated. Good to see people working on it. At the moment I think the simplest fix for zwiki users is still to rebuild python with stack size 1<<20.

Yikes --PieterB, 2003/06/22 12:09 GMT reply

> This seems to be getting still more complicated. Good to see people working on
> it. At the moment I think the simplest fix for zwiki users is still to rebuild
> python with stack size 1<<20.

I wouldn't call that a fix. More of a workaround ;)

Pieter

Python 2.3 on FreeBSD? -- Thu, 12 May 2005 16:54:33 -0700 reply
If you want to have this workaround also on Python 2.3 on FreeBSD?, you should set the option "HUGE STACK SIZE" to on, when you install the lang/python23 port. Jochen