Threaded Cygwin Python Import Problem

Jason Tishler
Mon Jul 16 10:56:00 GMT 2001


On Mon, Jul 16, 2001 at 01:12:23PM -0400, Greg Smith wrote:
> Jason Tishler wrote:
> > Yes! (I'm relieved that it was not just me!)  If you kill the child,
> > then you should see the following:
> > 
> >     $ ./python ../nothreads/
> >     child execvp-ing
> >     status = 15
> >     parent done
> > 
> Yes, this is exactly what I see.


> > Instead if you attach to the child, then you should see a stack trace
> > like the one in the following:
> Hmmm, gdb attach to the child process didn't cause a stackdump for me...

You won't get a stackdump, but you can see a stack trace by doing the

    $ # window number 1
    $ ./python ../nothreads/
    child execvp-ing

    $ # window number 2
    $ ps | fgrep python
           90     273      90        236    0 1004 13:32:12 /home/jt/src/Python-2.1/threads/python
          382      90      90        382    0 1004 13:32:13 /home/jt/src/Python-2.1/threads/python
    $ gdb -nw python.exe 
    GNU gdb 5.0 (20010428-1)
    (gdb) attach 382
    Attaching to program `/home/jt/src/Python-2.1/threads/python.exe', process 382
    [Switching to thread 382.0x19e]
    (gdb) thread 1
    [Switching to thread 1 (thread 382.0x14c)]#0  0x77f6829b in ?? ()
    (gdb) bt
    #0  0x77f6829b in ?? ()
    #1  0x77f04f41 in ?? ()
    #2  0x6105f14a in pthread_mutex::Lock (this=0xa014e10)
        at ../../../../src/winsup/cygwin/
> but I haven't compiled Python or Cygwin with -g either, also I am using
> the dll built from the 7/4 snapshot.

IIRC, Python is compiled with -g by default.  However, you will have to
build Cygwin yourself to get a non-stripped DLL that corresponds to your

> Anyway, at least I can produce the hang.  I won't be able to do any debugging
> until I get home later, but half the work in solving a problem is recreating
> the problem !!  I'll be back.


BTW, I was able to reproduce the hang under Windows 2000 SP1 if I
invoke python as follows:

    $ ./python ../nothreads/ </dev/null

Go figure!

Are wondering how I stumbled across this?  It is because I have a
version of Python built with --with-pydebug that prompts just before
exit to print out the remaining (object) references (I presume for
resource leak, garbage collection, etc. issues):

    $ ./python ../nothreads/
    Adding parser accelerators ...
    child execvp-ing
    status = 15
    parent done
    [3397 refs]
    Print left references? [ny] 

I thought that redirecting stdin to /dev/null would prevent the annoying
prompt -- instead it enabled the conditions necessary for the hang.
Maybe you can try this "technique" on your home machine so you can work
on this in the comfort of your own home?  :,)

Anyway, attached is a Windows 2000 SP1 stack trace of the problem.  The
stack trace is essentially the same as the one from NT 4.0 SP5.


Jason Tishler
Director, Software Engineering       Phone: 732.264.8770 x235
Dot Hill Systems Corp.               Fax:   732.264.8798
82 Bethany Road, Suite 7             Email:
Hazlet, NJ 07730 USA                 WWW:

More information about the Cygwin-developers mailing list