1.5.25: Python IOError on closing /dev/urandom after read (errno 0)

Michael Hoffman b3i4old02@sneakemail.com
Fri Jan 18 03:38:00 GMT 2008


The following produces an IOError:

====
$ cat > urand.py << __EOF__
urandomfile = open("/dev/urandom")
urandomfile.read(1)
urandomfile.close()
__EOF__

$ python urand.py
Traceback (most recent call last):
   File "urand.py", line 3, in <module>
     urandomfile.close()
IOError: [Errno 0] Error
====

Here is what I think the relevant section of an strace is:
====
    18  755530 [main] python 2240 open: 3 = open (/dev/urandom, 0x0)
    33  755563 [main] python 2240 _cygwin_istext_for_stdio: fd 3: opened 
as binary
    62  755625 [main] python 2240 fhandler_base::fstat: here
    19  755644 [main] python 2240 fstat64: 0 = fstat (3, 0x22C770)
    68  755712 [main] python 2240 fhandler_base::fstat: here
    18  755730 [main] python 2240 fstat64: 0 = fstat (3, 0x22C670)
    35  755765 [main] python 2240 isatty: 0 = isatty (3)
    19  755784 [main] python 2240 sig_send: sendsig 0x6FC, pid 2240, 
signal -34, its_me 1
    21  755805 [main] python 2240 sig_send: wakeup 0x6F8
    22  755827 [main] python 2240 sig_send: Waiting for pack.wakeup 0x6F8
    21  755848 [sig] python 2240 wait_sig: signalling pack.wakeup 0x6F8
    26  755874 [main] python 2240 sig_send: returning 0x0 from sending 
signal -34
    20  755894 [main] python 2240 readv: readv (3, 0x22C690, 1) 
blocking, sigcatchers 1
    19  755913 [main] python 2240 readv: no need to call ready_for_read
15018  770931 [main] python 2240 readv: 65536 = readv (3, 0x22C690, 1), 
errno 0
   115  771046 [main] python 2240 lseek64: 0 = lseek (3, 0, 1)
    20  771066 [main] python 2240 lseek64: 0 = lseek (3, -65535, 0)
    34  771100 [main] python 2240 close: close (3)
    29  771129 [main] python 2240 close: 0 = close (3)
   199  771328 [main] python 2240 sig_send: sendsig 0x6FC, pid 2240, 
signal -34, its_me 1
    23  771351 [main] python 2240 sig_send: wakeup 0x6F8
    23  771374 [main] python 2240 sig_send: Waiting for pack.wakeup 0x6F8
    76  771450 [sig] python 2240 wait_sig: signalling pack.wakeup 0x6F8
    46  771496 [main] python 2240 sig_send: returning 0x0 from sending 
signal -34
   113  771609 [main] python 2240 fhandler_base::write: binary write
    93  771702 [main] python 2240 sig_send: sendsig 0x6FC, pid 2240, 
signal -34, its_me 1
    23  771725 [main] python 2240 sig_send: wakeup 0x6F8
    24  771749 [main] python 2240 sig_send: Waiting for pack.wakeup 0x6F8
    23  771772 [sig] python 2240 wait_sig: signalling pack.wakeup 0x6F8
   121  771893 [main] python 2240 sig_send: returning 0x0 from sending 
signal -34
    22  771915 [main] python 2240 open: open (urand.py, 0x10000)
    37  772436 [main] python 2240 _cygwin_istext_for_stdio: fd 3: opened 
as binary
    61  772497 [main] python 2240 sig_send: sendsig 0x6FC, pid 2240, 
signal -34, its_me 1
    23  772520 [main] python 2240 sig_send: wakeup 0x6E4
    24  772544 [main] python 2240 sig_send: Waiting for pack.wakeup 0x6E4
    24  772568 [sig] python 2240 wait_sig: signalling pack.wakeup 0x6E4
    26  772594 [main] python 2240 sig_send: returning 0x0 from sending 
signal -34
    38  772632 [main] python 2240 fhandler_base::write: binary write
    86  772718 [main] python 2240 get_file_attribute: file: C:\Documents 
and Settings\Michael\src\experimental\urand\urand.py
   202  772920 [main] python 2240 cygpsid::debug_print: get_sids_info: 
owner SID = S-1-5-21-1343024091-1078145449-839522115-1003
    36  772956 [main] python 2240 cygpsid::debug_print: get_sids_info: 
group SID = S-1-5-21-1343024091-1078145449-839522115-513
    35  772991 [main] python 2240 get_info_from_sd: ACL 1ED, uid 1003, 
gid 513
    59  773050 [main] python 2240 fhandler_base::fstat_helper: 0 = fstat 
(, 0x22BFA0) st_atime=478FCAD9 st_size=75, st_mode=0x81ED, 
st_ino=1125899906973171, sizeof=96
    34  773084 [main] python 2240 fstat64: 0 = fstat (3, 0x22BFA0)
    58  773142 [main] python 2240 sig_send: sendsig 0x6FC, pid 2240, 
signal -34, its_me 1
    23  773165 [main] python 2240 sig_send: wakeup 0x6E4
    22  773187 [main] python 2240 sig_send: Waiting for pack.wakeup 0x6E4
    47  773234 [sig] python 2240 wait_sig: signalling pack.wakeup 0x6E4
    27  773261 [main] python 2240 sig_send: returning 0x0 from sending 
signal -34
    21  773282 [main] python 2240 readv: readv (3, 0x22BFC0, 1) 
blocking, sigcatchers 1
    19  773301 [main] python 2240 readv: no need to call ready_for_read
    41  773342 [main] python 2240 fhandler_base::read: returning 75, 
binary mode
    21  773363 [main] python 2240 readv: 75 = readv (3, 0x22BFC0, 1), 
errno 0
   116  773479 [main] python 2240 sig_send: sendsig 0x6FC, pid 2240, 
signal -34, its_me 1
    20  773499 [main] python 2240 sig_send: wakeup 0x6E4
    22  773521 [main] python 2240 sig_send: Waiting for pack.wakeup 0x6E4
    22  773543 [sig] python 2240 wait_sig: signalling pack.wakeup 0x6E4
    25  773568 [main] python 2240 sig_send: returning 0x0 from sending 
signal -34
    35  773603 [main] python 2240 fhandler_base::write: binary write
    65  773668 [main] python 2240 sig_send: sendsig 0x6FC, pid 2240, 
signal -34, its_me 1
    21  773689 [main] python 2240 sig_send: wakeup 0x6E4
    21  773710 [main] python 2240 sig_send: Waiting for pack.wakeup 0x6E4
    21  773731 [sig] python 2240 wait_sig: signalling pack.wakeup 0x6E4
    35  773766 [main] python 2240 sig_send: returning 0x0 from sending 
signal -34
    41  773807 [main] python 2240 fhandler_base::write: binary write
   120  773927 [main] python 2240 close: close (3)
    21  773948 [main] python 2240 fhandler_base::close: closing 
'/home/Michael/src/experimental/urand/urand.py' handle 0x6F8
    28  773976 [main] python 2240 close: 0 = close (3)
    97  774073 [main] python 2240 sig_send: sendsig 0x6FC, pid 2240, 
signal -34, its_me 1
    27  774100 [main] python 2240 sig_send: wakeup 0x6F8
    26  774126 [main] python 2240 sig_send: Waiting for pack.wakeup 0x6F8
    23  774149 [sig] python 2240 wait_sig: signalling pack.wakeup 0x6F8
    26  774175 [main] python 2240 sig_send: returning 0x0 from sending 
signal -34
    39  774214 [main] python 2240 fhandler_base::write: binary write
    80  774294 [main] python 2240 sig_send: sendsig 0x6FC, pid 2240, 
signal -34, its_me 1
    23  774317 [main] python 2240 sig_send: wakeup 0x6F8
    24  774341 [main] python 2240 sig_send: Waiting for pack.wakeup 0x6F8
    23  774364 [sig] python 2240 wait_sig: signalling pack.wakeup 0x6F8
    26  774390 [main] python 2240 sig_send: returning 0x0 from sending 
signal -34
    39  774429 [main] python 2240 fhandler_base::write: binary write
    74  774503 [main] python 2240 sig_send: sendsig 0x6FC, pid 2240, 
signal -34, its_me 1
    22  774525 [main] python 2240 sig_send: wakeup 0x6F8
    24  774549 [main] python 2240 sig_send: Waiting for pack.wakeup 0x6F8
    23  774572 [sig] python 2240 wait_sig: signalling pack.wakeup 0x6F8
    26  774598 [main] python 2240 sig_send: returning 0x0 from sending 
signal -34
    38  774636 [main] python 2240 fhandler_base::write: binary write
    73  774709 [main] python 2240 sig_send: sendsig 0x6FC, pid 2240, 
signal -34, its_me 1
   127  774836 [main] python 2240 sig_send: wakeup 0x6F8
    35  774871 [main] python 2240 sig_send: Waiting for pack.wakeup 0x6F8
    44  774915 [sig] python 2240 wait_sig: signalling pack.wakeup 0x6F8
    56  774971 [main] python 2240 sig_send: returning 0x0 from sending 
signal -34
    58  775029 [main] python 2240 fhandler_base::write: binary write
    62  775091 [main] python 2240 sig_send: sendsig 0x6FC, pid 2240, 
signal -34, its_me 1
    22  775113 [main] python 2240 sig_send: wakeup 0x6F8
    22  775135 [main] python 2240 sig_send: Waiting for pack.wakeup 0x6F8
    21  775156 [sig] python 2240 wait_sig: signalling pack.wakeup 0x6F8
    25  775181 [main] python 2240 sig_send: returning 0x0 from sending 
signal -34
    20  775201 [main] python 2240 sigaction_worker: signal 2, newact 
0x22CB50 (handler 0x0), oa 0x6CB704D0
====

There is no error if I change read(1) to read(0). The strace now looks 
like this:

====
    22  737985 [main] python 624 open: open (/dev/urandom, 0x0)
    21  738006 [main] python 624 normalize_posix_path: src /dev/urandom
    20  738026 [main] python 624 normalize_posix_path: /dev/urandom = 
normalize_posix_path (/dev/urandom)
    21  738047 [main] python 624 mount_info::conv_to_win32_path: 
conv_to_win32_path (/dev/urandom)
    21  738068 [main] python 624 mount_info::conv_to_win32_path: 
src_path /dev/urandom, dst \dev\urandom, flags 0x2, rc 0
    26  738094 [main] python 624 build_fh_pc: fh 0x61169E50
    21  738115 [main] python 624 fhandler_base::set_flags: flags 
0x10000, supplied_bin 0x0
    20  738135 [main] python 624 fhandler_base::set_flags: 
O_TEXT/O_BINARY set in flags 0x10000
    21  738156 [main] python 624 fhandler_base::set_flags: filemode set 
to binary
    20  738176 [main] python 624 open: 3 = open (/dev/urandom, 0x0)
    36  738212 [main] python 624 _cygwin_istext_for_stdio: fd 3: opened 
as binary
    68  738280 [main] python 624 fhandler_base::fstat: here
    20  738300 [main] python 624 fstat64: 0 = fstat (3, 0x22C770)
   134  738434 [main] python 624 close: close (3)
    59  738493 [main] python 624 close: 0 = close (3)
   149  738642 [main] python 624 sig_send: sendsig 0x6FC, pid 624, 
signal -34, its_me 1
    24  738666 [main] python 624 sig_send: wakeup 0x6F8
    23  738689 [main] python 624 sig_send: Waiting for pack.wakeup 0x6F8
    24  738713 [sig] python 624 wait_sig: signalling pack.wakeup 0x6F8
    25  738738 [main] python 624 sig_send: returning 0x0 from sending 
signal -34
    22  738760 [main] python 624 sigaction_worker: signal 2, newact 
0x22CB50 (handler 0x0), oa 0x6CB704D0
====

A consequence of this error reviously reported at 
<https://bugs.launchpad.net/bzr/+bug/181855>.

I would love it if anyone had suggestions. Thanks in advance.
-- 
Michael
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cygcheck.out
URL: <http://cygwin.com/pipermail/cygwin/attachments/20080118/1c4089bb/attachment.ksh>
-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list