msvcrt: sharing violation caused by duplicated hande in
_get_osfhandle
qingdoa daoo
qingdao33122 at yahoo.com
Fri Apr 14 01:03:47 CDT 2006
Hi,
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);
_close(fd);
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
anymore.
---------------------------------
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...
URL: http://www.winehq.org/pipermail/wine-devel/attachments/20060413/3b7499a5/attachment-0001.htm
More information about the wine-devel
mailing list