http://bugs.winehq.org/show_bug.cgi?id=10032
Summary: Wine must not use unix select() for networking where there might be high fd's Product: Wine Version: CVS/GIT Platform: Other OS/Version: other Status: NEW Keywords: patch Severity: normal Priority: P2 Component: wine-net AssignedTo: wine-bugs@winehq.org ReportedBy: dank@kegel.com
select() cannot handle fds higher than FD_SETSIZE. Thus if you open a lot of plain old files, then create one socket and try to use a networking function based on select(), you're hosed.
This actually happened recently during soak testing of an app doing lots of wininet stuff, which tickled a socket leak in wininet (see http://winehq.org/pipermail/wine-patches/2007-October/045089.html for the leak fix). This was a wake-up call for us; the app in question is fine after the leak fix, but an app that really used lots of file descriptors would hit the bug in a bad way.
Here's how to find all the suspicious calls to select(): $ find . -name '*.c' | xargs grep '[^a-z]select[^a-zA-Z]*(.*&' | grep -v '/tests/' Calls where select is used with no fd's are ok, since they can't run into the problem. Calls which use a winsock select() instead of a unix select() might be ok (e.g. netapi32/nbt.c), since winsock's select doesn't have a fixed FD_SETSIZE. Only two problematic calls remain:
wininet/internet.c: if (select(nSocket+1,&infd,NULL,NULL,&tv) > 0) wininet/netconnection.c: if (select(connection->socketFD+1,&infd,NULL,NULL,&tv) > 0)
These must be replaced with poll(), which can handle high fd's.
This was discussed last November, http://www.winehq.org/pipermail/wine-devel/2006-November/052099.html and Damjan submitted patches to fix them: http://www.winehq.org/pipermail/wine-patches/2006-November/032529.html http://www.winehq.org/pipermail/wine-patches/2006-November/032530.html but these patches don't seem to have been applied yet. Time to get them in!
http://bugs.winehq.org/show_bug.cgi?id=10032
Dan Kegel dank@kegel.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |1.0.0
--- Comment #1 from Dan Kegel dank@kegel.com 2007-10-14 11:18:59 --- This is a 1.0 must-fix bug.
http://bugs.winehq.org/show_bug.cgi?id=10032
Damjan Jovanovic damjan.jov@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |damjan.jov@gmail.com
--- Comment #2 from Damjan Jovanovic damjan.jov@gmail.com 2007-10-15 00:39:42 --- I believe the complication with wininet's select() was that if you use poll() instead, you can't compile a native DLL with mingw.
http://bugs.winehq.org/show_bug.cgi?id=10032
--- Comment #3 from Dan Kegel dank@kegel.com 2007-11-25 23:48:26 --- Why do we care if you can build a wininet.dll with mingw?
http://bugs.winehq.org/show_bug.cgi?id=10032
--- Comment #4 from Damjan Jovanovic damjan.jov@gmail.com 2007-11-25 23:56:30 --- It makes it possible to use wine's DLLs on Windows for testing and such. Wininet already supports being built with mingw, it would be a shame to lose that. My patches got mingw building with both wine and mingw (I had #ifdef sections which use poll on Linux and select on Windows), but for some reason they weren't accepted.
http://bugs.winehq.org/show_bug.cgi?id=10032
--- Comment #5 from Dan Kegel dank@kegel.com 2007-11-26 06:08:09 --- Thanks for the explanation.
Would you consider resubmitting without the #ifdef's, and maintaining the mingw compatibility patch out of tree?
http://bugs.winehq.org/show_bug.cgi?id=10032
Steven Edwards winehacker@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |winehacker@gmail.com
--- Comment #6 from Steven Edwards winehacker@gmail.com 2007-12-19 06:21:02 ---
Would you consider resubmitting without the #ifdef's, and maintaining the mingw compatibility patch out of tree?
-1 on maintaining compatibility patches out of the tree. I spent a lot of time getting wininet working and building mingw/msvc and this amounts to throwing away my work. It can and should be fixed for both cases.
http://bugs.winehq.org/show_bug.cgi?id=10032
--- Comment #7 from Alexandre Julliard julliard@winehq.org 2007-12-19 13:15:26 --- There's no reason to clutter up the code with #ifdefs. It's easy to provide a poll() substitute in libport for Mingw.
http://bugs.winehq.org/show_bug.cgi?id=10032
Kai Blin blin@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED
--- Comment #8 from Kai Blin blin@gmx.net 2008-03-24 07:13:11 --- Patch sent.
http://bugs.winehq.org/show_bug.cgi?id=10032
Kai Blin kai.blin@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution| |FIXED
--- Comment #9 from Kai Blin kai.blin@gmail.com 2008-03-24 09:21:25 --- Committed in 63504e9e80acb35666f8689526c67dd99c4fb3ba
http://bugs.winehq.org/show_bug.cgi?id=10032
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #10 from Alexandre Julliard julliard@winehq.org 2008-04-04 10:06:03 --- Closing bugs fixed in 0.9.59.
http://bugs.winehq.org/show_bug.cgi?id=10032
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Version|CVS/GIT |unspecified