[Python-bugs-list] [ python-Bugs-210667 ] select module: Bug in select.select() (PR#365)

noreply@sourceforge.net noreply@sourceforge.net
Thu, 03 Jan 2002 21:05:52 -0800


Bugs item #210667, was opened at 2000-07-31 14:12
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=210667&group_id=5470

Category: Extension Modules
Group: Platform-specific
Status: Closed
Resolution: Works For Me
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: A.M. Kuchling (akuchling)
Summary: select module: Bug in select.select() (PR#365)

Initial Comment:
Jitterbug-Id: 365
Submitted-By: r32813@email.sps.mot.com
Date: Wed, 21 Jun 2000 12:00:54 -0400 (EDT)
Version: 1.5.2
OS: AIX 4.3.1


 The python 1.5.2 built on AIX 4.3.1.0 platform created a coredump when 
 this command was run:-
 
       select.select(waitList, [], [], timeWait)
 
 This command worked fine in Python 1.5.1 build and also fine on Python
 1.5.2 built on HP 10.2. It just didn't work in AIX 4.3.1.0 build on
 2 AIX machines that we have. 

 






====================================================================
Audit trail:
Tue Jul 11 08:24:19 2000	guido	moved from incoming to open

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2002-01-03 21:05

Message:
Logged In: NO 

this appears to be a stack problem, which would explain the 
mysterious backtrace. on AIX (4.3.3), the FD_SETSIZE is 
32k, so at 12 bytes per array and 3 arrays of 32k, that is 
a little over 1Mb on the stack. there is already some code 
to handle this for Windows, so adding an additional check 
for AIX should fix the problem. of course it would be nicer 
for a solution that didn't need to allocate and free all 
that memory every time select is called.

----------------------------------------------------------------------

Comment By: A.M. Kuchling (akuchling)
Date: 2000-09-28 15:21

Message:
It seems impossible to reproduce this without actually having an AIX box, and IBM has no equivalent of Compaq's
test drive, unfortunately.

At first blush, it's difficult to come up with
a hypothesis; why would the *tout = Py_None line cause 
a segfault?  Perhaps a refcounting bug 
decreased the RC of _Py_None_struct to 0 
and caused it to be deallocated, but that shouldn't crash
on that line of code.

I'm going to mark this "Works for Me", pending 
further reports from the original submitter, or from
anyone else.  


----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2000-09-22 21:55

Message:
Just putting the fellow's test_thread_select.py here as plain text (it's given only as base64 below):

# Testing select module
from test_support import verbose
import select, thread, Queue
import os

# test some known error conditions
try:
    rfd, wfd, xfd = select.select(1, 2, 3)
except TypeError:
    pass
else:
    print 'expected TypeError exception not raised'

class Nope:
    pass

class Almost:
    def fileno(self):
        return 'fileno'
    
try:
    rfd, wfd, xfd = select.select([Nope()], [], [])
except TypeError:
    pass
else:
    print 'expected TypeError exception not raised'

try:
    rfd, wfd, xfd = select.select([Almost()], [], [])
except TypeError:
    pass
else:
    print 'expected TypeError exception not raised'


def test(q):
        import sys
        if sys.platform[:3] in ('win', 'mac', 'os2'):
                if verbose:
                        print "Can't test select easily on", sys.platform
                return
        cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done'
        p = os.popen(cmd, 'r')
        for tout in (0, 1, 2, 4, 8, 16) + (None,)*10:
                if verbose:
                        print 'timeout =', tout
                rfd, wfd, xfd = select.select([p], [], [], tout)
##              print rfd, wfd, xfd
                if (rfd, wfd, xfd) == ([], [], []):
                        continue
                if (rfd, wfd, xfd) == ([p], [], []):
                        line = p.readline()
                        if verbose:
                                print `line`
                        if not line:
                                if verbose:
                                        print 'EOF'
                                break
                        continue
                print 'Heh?'
        p.close()
        q.put(1)


q = Queue.Queue(1)
thread.start_new_thread(test,(q,))
#wait for thread to complete test function
done = q.get()
print 'thread completed test, exiting'


----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2000-08-01 14:01

Message:
From: Guido van Rossum <guido@python.org>
Subject: Re: [Python-bugs-list] select module: Bug in select.select() (PR#365)
Date: Fri, 23 Jun 2000 11:01:40 -0500

> Below is the dbx information from the coredump. This only occurs when the
> select.select() function is used within a thread. This same error occurs on
> both Python 1.5.1 and Python 1.5.2 when AIX 4.3.1. This problem does not
> occur on AIX 4.1.4.
> 
> $ dbx -I ./Modules ./python core
> Type 'help' for help.
> reading symbolic information ...
> [using memory image in core]
> 
> Segmentation fault in initselect at line 235 in file "Modules/selectmodule.c"
> ($t2)
>   235           PyObject *tout = Py_None;

Thanks.  Could you do this again and also type the "bt" (backtrace)
command?  That would perhaps be more helpful.  We can't reproduce this
here since we don't have access to AIX!  (Even if we ha,d it would be
low priority :-( ).

--Guido van Rossum (home page: http://www.python.org/~guido/)



----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2000-08-01 14:01

Message:
From: "Wahmeng Wong" <r32813@email.sps.mot.com>
Subject: Re: [Python-bugs-list] select module: Bug in select.select() (PR#365)
Date: Thu, 22 Jun 2000 19:02:11 -0700

This is a multi-part message in MIME format.
--------------F9E74BCE6963FE221E423528
Content-Type: multipart/alternative;
 boundary="------------FF8E270086909CA1DBDDA697"


--------------FF8E270086909CA1DBDDA697
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi Guido,

Below is the dbx information from the coredump. This only occurs when the
select.select() function is used within a thread. This same error occurs on
both Python 1.5.1 and Python 1.5.2 when AIX 4.3.1. This problem does not
occur on AIX 4.1.4.

$ dbx -I ./Modules ./python core
Type 'help' for help.
reading symbolic information ...
[using memory image in core]

Segmentation fault in initselect at line 235 in file "Modules/selectmodule.c"
($t2)
  235           PyObject *tout = Py_None;

We have been able to reproduce the coredump by modifying the test_select.py
to perform the test within a thread. Attached is the modified file called
test_thread_select.py. Just place this file in the Lib/test directory to see
this problem.

Thanks for all your help.

Regards,
Wah Meng

Guido van Rossum wrote:

> >  The python 1.5.2 built on AIX 4.3.1.0 platform created a coredump when
> >  this command was run:-
> >
> >        select.select(waitList, [], [], timeWait)
> >
> >  This command worked fine in Python 1.5.1 build and also fine on Python
> >  1.5.2 built on HP 10.2. It just didn't work in AIX 4.3.1.0 build on
> >  2 AIX machines that we have.
>
> Could you give us some more information?  You're indicating that it's
> platform specific; we don't have an AIX box.  I'm guessing it's not
> obvious that our code is wrong, but it may violate some guidelines
> given by AIX manuals.  If we ever want to fix this, we'll need to
> interact with you.  the first thing we need is a decent stack trace;
> we'll take it from there.
>
> If you could investigate this on your own and come up with a fix, that
> would probably the best solution...
>
> --Guido van Rossum (home page: http://www.python.org/~guido/)

--------------FF8E270086909CA1DBDDA697
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hi Guido,
<p>Below is the dbx information from the coredump. This only occurs when
the select.select() function is used within a thread. This same error occurs
on both Python 1.5.1 and Python 1.5.2 when AIX 4.3.1. This problem does
not occur on AIX 4.1.4.
<p><tt>$ dbx -I ./Modules ./python core</tt>
<br><tt>Type 'help' for help.</tt>
<br><tt>reading symbolic information ...</tt>
<br><tt>[using memory image in core]</tt><tt></tt>
<p><tt>Segmentation fault in initselect at line 235 in file "Modules/selectmodule.c"
($t2)</tt>
<br><tt>&nbsp; 235&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
PyObject *tout = Py_None;</tt>
<p>We have been able to reproduce the coredump by modifying the test_select.py
to perform the test within a thread. Attached is the modified file called
test_thread_select.py. Just place this file in the Lib/test directory to
see this problem.
<p>Thanks for all your help.
<p>Regards,
<br>Wah Meng
<p>Guido van Rossum wrote:
<blockquote TYPE=CITE>>&nbsp; The python 1.5.2 built on AIX 4.3.1.0 platform
created a coredump when
<br>>&nbsp; this command was run:-
<br>>
<br>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select.select(waitList,
[], [], timeWait)
<br>>
<br>>&nbsp; This command worked fine in Python 1.5.1 build and also fine
on Python
<br>>&nbsp; 1.5.2 built on HP 10.2. It just didn't work in AIX 4.3.1.0
build on
<br>>&nbsp; 2 AIX machines that we have.
<p>Could you give us some more information?&nbsp; You're indicating that
it's
<br>platform specific; we don't have an AIX box.&nbsp; I'm guessing it's
not
<br>obvious that our code is wrong, but it may violate some guidelines
<br>given by AIX manuals.&nbsp; If we ever want to fix this, we'll need
to
<br>interact with you.&nbsp; the first thing we need is a decent stack
trace;
<br>we'll take it from there.
<p>If you could investigate this on your own and come up with a fix, that
<br>would probably the best solution...
<p>--Guido van Rossum (home page: <a href="http://www.python.org/~guido/">http://www.python.org/~guido/</a>)</blockquote>
</html>

--------------FF8E270086909CA1DBDDA697--

--------------F9E74BCE6963FE221E423528
Content-Type: application/x-unknown-content-type-Python.File;
 name="test_thread_select.py"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 filename="test_thread_select.py"

IyBUZXN0aW5nIHNlbGVjdCBtb2R1bGUNCmZyb20gdGVzdF9zdXBwb3J0IGltcG9ydCB2ZXJi
b3NlDQppbXBvcnQgc2VsZWN0LCB0aHJlYWQsIFF1ZXVlDQppbXBvcnQgb3MNCg0KIyB0ZXN0
IHNvbWUga25vd24gZXJyb3IgY29uZGl0aW9ucw0KdHJ5Og0KICAgIHJmZCwgd2ZkLCB4ZmQg
PSBzZWxlY3Quc2VsZWN0KDEsIDIsIDMpDQpleGNlcHQgVHlwZUVycm9yOg0KICAgIHBhc3MN
CmVsc2U6DQogICAgcHJpbnQgJ2V4cGVjdGVkIFR5cGVFcnJvciBleGNlcHRpb24gbm90IHJh
aXNlZCcNCg0KY2xhc3MgTm9wZToNCiAgICBwYXNzDQoNCmNsYXNzIEFsbW9zdDoNCiAgICBk
ZWYgZmlsZW5vKHNlbGYpOg0KICAgICAgICByZXR1cm4gJ2ZpbGVubycNCiAgICANCnRyeToN
CiAgICByZmQsIHdmZCwgeGZkID0gc2VsZWN0LnNlbGVjdChbTm9wZSgpXSwgW10sIFtdKQ0K
ZXhjZXB0IFR5cGVFcnJvcjoNCiAgICBwYXNzDQplbHNlOg0KICAgIHByaW50ICdleHBlY3Rl
ZCBUeXBlRXJyb3IgZXhjZXB0aW9uIG5vdCByYWlzZWQnDQoNCnRyeToNCiAgICByZmQsIHdm
ZCwgeGZkID0gc2VsZWN0LnNlbGVjdChbQWxtb3N0KCldLCBbXSwgW10pDQpleGNlcHQgVHlw
ZUVycm9yOg0KICAgIHBhc3MNCmVsc2U6DQogICAgcHJpbnQgJ2V4cGVjdGVkIFR5cGVFcnJv
ciBleGNlcHRpb24gbm90IHJhaXNlZCcNCg0KDQpkZWYgdGVzdChxKToNCiAgICAgICAgaW1w
b3J0IHN5cw0KICAgICAgICBpZiBzeXMucGxhdGZvcm1bOjNdIGluICgnd2luJywgJ21hYycs
ICdvczInKToNCiAgICAgICAgICAgICAgICBpZiB2ZXJib3NlOg0KICAgICAgICAgICAgICAg
ICAgICAgICAgcHJpbnQgIkNhbid0IHRlc3Qgc2VsZWN0IGVhc2lseSBvbiIsIHN5cy5wbGF0
Zm9ybQ0KICAgICAgICAgICAgICAgIHJldHVybg0KICAgICAgICBjbWQgPSAnZm9yIGkgaW4g
MCAxIDIgMyA0IDUgNiA3IDggOTsgZG8gZWNobyB0ZXN0aW5nLi4uOyBzbGVlcCAxOyBkb25l
Jw0KICAgICAgICBwID0gb3MucG9wZW4oY21kLCAncicpDQogICAgICAgIGZvciB0b3V0IGlu
ICgwLCAxLCAyLCA0LCA4LCAxNikgKyAoTm9uZSwpKjEwOg0KICAgICAgICAgICAgICAgIGlm
IHZlcmJvc2U6DQogICAgICAgICAgICAgICAgICAgICAgICBwcmludCAndGltZW91dCA9Jywg
dG91dA0KICAgICAgICAgICAgICAgIHJmZCwgd2ZkLCB4ZmQgPSBzZWxlY3Quc2VsZWN0KFtw
XSwgW10sIFtdLCB0b3V0KQ0KIyMgICAgICAgICAgICAgIHByaW50IHJmZCwgd2ZkLCB4ZmQN
CiAgICAgICAgICAgICAgICBpZiAocmZkLCB3ZmQsIHhmZCkgPT0gKFtdLCBbXSwgW10pOg0K
ICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWUNCiAgICAgICAgICAgICAgICBpZiAo
cmZkLCB3ZmQsIHhmZCkgPT0gKFtwXSwgW10sIFtdKToNCiAgICAgICAgICAgICAgICAgICAg
ICAgIGxpbmUgPSBwLnJlYWRsaW5lKCkNCiAgICAgICAgICAgICAgICAgICAgICAgIGlmIHZl
cmJvc2U6DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaW50IGBsaW5lYA0K
ICAgICAgICAgICAgICAgICAgICAgICAgaWYgbm90IGxpbmU6DQogICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgIGlmIHZlcmJvc2U6DQogICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgcHJpbnQgJ0VPRicNCiAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgYnJlYWsNCiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlDQogICAgICAg
ICAgICAgICAgcHJpbnQgJ0hlaD8nDQogICAgICAgIHAuY2xvc2UoKQ0KICAgICAgICBxLnB1
dCgxKQ0KDQoNCnEgPSBRdWV1ZS5RdWV1ZSgxKQ0KdGhyZWFkLnN0YXJ0X25ld190aHJlYWQo
dGVzdCwocSwpKQ0KI3dhaXQgZm9yIHRocmVhZCB0byBjb21wbGV0ZSB0ZXN0IGZ1bmN0aW9u
DQpkb25lID0gcS5nZXQoKQ0KcHJpbnQgJ3RocmVhZCBjb21wbGV0ZWQgdGVzdCwgZXhpdGlu
ZycNCg0K
--------------F9E74BCE6963FE221E423528--




----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2000-08-01 14:01

Message:
From: Guido van Rossum <guido@python.org>
Subject: Re: [Python-bugs-list] select module: Bug in select.select() (PR#365)
Date: Wed, 21 Jun 2000 17:08:33 -0500

>  The python 1.5.2 built on AIX 4.3.1.0 platform created a coredump when 
>  this command was run:-
>  
>        select.select(waitList, [], [], timeWait)
>  
>  This command worked fine in Python 1.5.1 build and also fine on Python
>  1.5.2 built on HP 10.2. It just didn't work in AIX 4.3.1.0 build on
>  2 AIX machines that we have. 

Could you give us some more information?  You're indicating that it's
platform specific; we don't have an AIX box.  I'm guessing it's not
obvious that our code is wrong, but it may violate some guidelines
given by AIX manuals.  If we ever want to fix this, we'll need to
interact with you.  the first thing we need is a decent stack trace;
we'll take it from there.

If you could investigate this on your own and come up with a fix, that
would probably the best solution...

--Guido van Rossum (home page: http://www.python.org/~guido/)



----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=210667&group_id=5470