relay log problem

Michael Stefaniuc mstefani at
Fri Jan 29 05:32:45 CST 2010

Alexandre Julliard wrote:
> Michael Stefaniuc <mstefani at> writes:
>> Incorrect. Wine doesn't use write(2) but vfprintf(3) which operates on
>> FILE handles; the output is buffered aka a vfprintf call won't translate
>> 1:1 to a write(2) system call. But even if it would directly use
>> write(2), that system call isn't atomic. A lot of people consider a
>> write smaller/equal the PAGE_SIZE to be atomic but it isn't; one can get
>> a short write because of an EINTR.
>> The ">>" redirection fixes the overwriting corruption but not the
>> interleaving one. With multiple threads and enough debug output the
>> chances are high to get a few interleaving corruption; i see it
>> regularly in the output of winetest.exe runs.
> No, Wine explicitly uses write(2) for debug output, and is careful about
> writing only complete lines precisely to avoid the interleaving issue.
Hmm ... I have looked at libs/wine/debug.c and not at NTDLL_dbg_vprintf().

Anyway the usage of write(2) in NTDLL_dbg_vprintf() is *wrong* as it
doesn't check for short writes nor errors. It is good enough for debug
output and better than using the FILE * functions but not good enough to
prevent interleaving. It even introduces an opportunity for parts of a
line to be overwritten in the case of short writes.

> It does require O_APPEND to ensure that the writes don't step over each
> other, which is why you need ">>". It definitely makes a difference.
Yes it does; it didn't disagree with this fact.


More information about the wine-devel mailing list