[Python-Dev] test_fork1 on SMP? (was Re: [Python Dev] test_fork1 failing --with-threads (for some people)...)

Neil Schemenauer nascheme@enme.ucalgary.ca
Wed, 9 Aug 2000 14:11:04 -0600


On Mon, Jul 31, 2000 at 04:42:50AM -0400, Tim Peters wrote:
> It's a baffler!  AFAIK, nobody yet has thought of a way that a fork can
> screw up the state of the locks in the *parent* process (it must be easy to
> see how they can get screwed up in a child, because two of us already did
> <wink>).

If I add Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS around fork()
in posixmodule then the child is the process which always seems to hang.
The child is hanging at:

#0  0x4006d58b in __sigsuspend (set=0xbf7ffac4)
    at ../sysdeps/unix/sysv/linux/sigsuspend.c:48
#1  0x4001f1a0 in pthread_cond_wait (cond=0x8264e1c, mutex=0x8264e28)
    at restart.h:49
#2  0x806f3c3 in PyThread_acquire_lock (lock=0x8264e18, waitflag=1)
    at thread_pthread.h:311
#3  0x80564a8 in PyEval_RestoreThread (tstate=0x8265a78) at ceval.c:178
#4  0x80bf274 in posix_fork (self=0x0, args=0x8226ccc) at ./posixmodule.c:1659
#5  0x8059460 in call_builtin (func=0x82380e0, arg=0x8226ccc, kw=0x0)
    at ceval.c:2376
#6  0x8059378 in PyEval_CallObjectWithKeywords (func=0x82380e0, arg=0x8226ccc, 
    kw=0x0) at ceval.c:2344
#7  0x80584f2 in eval_code2 (co=0x8265e98, globals=0x822755c, locals=0x0, 
    args=0x8226cd8, argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, 
    owner=0x0) at ceval.c:1682
#8  0x805974b in call_function (func=0x8264ddc, arg=0x8226ccc, kw=0x0)
    at ceval.c:2498
#9  0x805936b in PyEval_CallObjectWithKeywords (func=0x8264ddc, arg=0x8226ccc, 
    kw=0x0) at ceval.c:2342
#10 0x80af26a in t_bootstrap (boot_raw=0x8264e00) at ./threadmodule.c:199
#11 0x4001feca in pthread_start_thread (arg=0xbf7ffe60) at manager.c:213

Since there is only one thread in the child this should not be
happening.  Can someone explain this?  I have tested this both a SMP
Linux machine and a UP Linux machine.

   Neil