msvcrt: sharing violation caused by duplicated hande in _get_osfhandle

qingdoa daoo qingdao33122 at
Fri Apr 14 01:03:47 CDT 2006

 wine's implementation of _get_osfhandle is found to cause sharing violation in some apps. The author commented this piece of code with a block of FIXME
 warning about possible leakage. It turns out it's no just a matter of leakage.
 A simple test program
 #include "windows.h"
 #include "io.h"
 #include "fcntl.h"
 #include "share.h"
 int main()
     int fd, bWritten;
     fd = _sopen("foo", _O_CREAT|_O_RDWR,_SH_DENYRW, 0);
     WriteFile((HANDLE)_get_osfhandle(fd), "bar", 3, &bWritten, NULL);
     fd = _open("foo", _O_RDONLY, 0);
     _write(1, fd==-1? "F\n" : "S\n", 2);
 The second _open fails with builtin msvcrt, not with native one.
 The comment  says that the duplication is to make an inheritable hande.
 With the recent change in msvcrt's io init procedure, that shouldn't be a problem
Blab-away for as little as 1¢/min. Make  PC-to-Phone Calls using Yahoo! Messenger with Voice.
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the wine-devel mailing list