Crash inside dup()

From: Gisle Vanem <>
Date: Thu, 19 Dec 2013 17:24:48 +0100

In pycurl.c, dup() is called to presumably duplicate a socket.
But sockets and files cannot be intermingled like on Unix.
Can WSADuplicateSocket() be used instead?

Anyway, the dup() crashes deep inside Win-XP and gives me only
this call-stack:


Not very helpful. I used something like this to test:

def socket_open(family, socktype, protocol, address):
   s = socket.socket (family, socktype, protocol)
   print ("s._sock: ", s._sock)
   return s

c = pycurl.Curl()
c.setopt(c.URL, '')
c.setopt(c.OPENSOCKETFUNCTION, socket_open)

Which produces this before the crash:
  ('s._sock: ', <socket object, fd=1444, family=2, type=1, protocol=0>)

The 1444 seems right and is the same arg as dup() is called with.


Received on 2013-12-19