[Python-bugs-list] [Bug #125891] windows popen4 crashes python when not closed correctly

noreply@sourceforge.net noreply@sourceforge.net
Mon, 18 Dec 2000 14:04:11 -0800


Bug #125891, was updated on 2000-Dec-15 05:53
Here is a current snapshot of the bug.

Project: Python
Category: Windows
Status: Open
Resolution: None
Bug Group: Platform-specific
Priority: 5
Submitted by: aisaksen
Assigned to : tim_one
Summary: windows popen4 crashes python when not closed correctly

Details: If you don't close both the istream file and ostream file return values after calling popen4, then it crashes in somewhere in MSVCRT.DLL

Try the code included in this file.  If you call Crash(), then python will crash after about 500 times through the loop.  NoCrash() works ok, because you close both of the results.  This bug happens on both the www.python.org release, as well as the ActivePython build.  I'm running Windows 2000, with Visual Studio 6.0 installed.

This seems to be a Windows bug.  It dies in a call to setvbuf.  Recompiling with the HAS_SETVBUF undefined still causes the same crash.  It would be nice if python prevented this from happening.  Ideally, you should be able to close the pipes, because there is no longer a reference to them.

-Aaron Isaksen

-- begin code --

import os

def Crash():
    n = 0
    while 1:
        p = os.popen4('dir')
        p[0].close()
        n +=1
        print n

def NoCrash():
    n = 0
    while 1:
        p = os.popen4('dir')
        p[0].close()
        p[1].close()
        n +=1
        print n

-- end code --

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=125891&group_id=5470