[New-bugs-announce] [issue20585] urllib2 unrelease KQUEUE on Mac OSX 10.9+

Andrew Gross report at bugs.python.org
Mon Feb 10 19:46:03 CET 2014

New submission from Andrew Gross:

In the latest OSX, 10.9, it looks like there have been some security changes related to inheriting file descriptors from parent to child processes.  While in the past it would allow you to inherit the parents open FDs, now it will kill the process. 

It looks like urllib2 does not properly unsubscribe from the KQUEUE after opening a remote connection, causing the process to be killed if you try use "evecv" style commands, or fork.

Simple Reproduction:
import urllib2
request = urllib2.urlopen('http://www.python.org')
response = request.read()
os.execvp('ssh', ['ssh', 'user at'])
# Killed: 9

I have attached the diagnostic crash report from OSX, appended to the end is a snippet from `lsof` showing the open KQUEUE file descriptor.

assignee: ronaldoussoren
components: Library (Lib), Macintosh
files: urllib2.crash
messages: 210860
nosy: Andrew.Gross, ronaldoussoren
priority: normal
severity: normal
status: open
title: urllib2 unrelease KQUEUE on Mac OSX 10.9+
type: crash
versions: Python 2.7
Added file: http://bugs.python.org/file34024/urllib2.crash

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list