[Python-Dev] Pervasive socket failures on Windows

Scott Dial scott+python-dev at scottdial.com
Fri Feb 10 06:02:25 CET 2006


Tim Peters wrote:
> I _suspect_ that rev 42253 introduced these problems.  For example, that added:
> 
> +       /* Guard against socket too large for select*/
> +       if (s->sock_fd >= FD_SETSIZE)
> +               return SOCKET_INVALID;
> 
> to _ssl.c, and added
> 
> +/* Can we call select() with this socket without a buffer overrun? */
> +#define IS_SELECTABLE(s) ((s)->sock_fd < FD_SETSIZE)
> 
> to socketmodule.c, but those appear to make no sense.  FD_SETSIZE is
> the maximum number of distinct fd's an fdset can hold, and the
> numerical magnitude of any specific fd has nothing to do with that in
> general (they may be related in fact on Unix systems that implement an
> fdset as "a big bit vector" -- but Windows doesn't work that way, and
> neither do all Unix systems, and nothing in socket specs requires an
> implementation to work that way).

Neal checked these changes in to address bug #876637 "Random stack 
corruption from socketmodule.c" But the Windows implementation of 
"select" is entirely different than other platforms, in so far as 
windows uses an internal counter to assign fds to an fd_set, so the fd 
number itself has no relevance to where they are placed in an fd_set. 
This stack corruption bug then does not exist on Windows, and so the 
code should not be used with Windows either.

-- 
Scott Dial
scott at scottdial.com
dialsa at rose-hulman.edu


More information about the Python-Dev mailing list