server: Avoid sending unexpected wakeup with uninitialized cookie value.

Sebastian Lackner sebastian at fds-team.de
Sat Nov 22 10:42:22 CST 2014


While executing the kernel32/sync tests I noticed a couple of unexpected wakeup cookies, which looked like uninitialized wineserver memory.
Here an excerpt from the log (added additional debug values):

--- snip ---
0009: select( flags=2, cookie=0033faac, timeout=0, prev_apc=0000, result={}, data={SIGNAL_AND_WAIT,signal=0038,wait=0038} )
0009: *wakeup* signaled=0 cookie=0x55555555
0009: select() = 0 { timeout=1d00663fadcfb0a (+0.0000000), call={APC_NONE}, apc_handle=0000 }
[...]
0009: select( flags=2, cookie=0033faac, timeout=0, prev_apc=0000, result={}, data={SIGNAL_AND_WAIT,signal=0038,wait=0038} )
0009: *wakeup* signaled=0 cookie=0x55555555
0009: select() = 0 { timeout=1d00663fadcfdf8 (+0.0000000), call={APC_NONE}, apc_handle=0000 }
[...]
0009: select( flags=2, cookie=0033f8dc, timeout=+0.0100000, prev_apc=0000, result={}, data={WAIT,handles={0038}} )
0009: select() = PENDING { timeout=1d00663fae61280 (+0.0100000), call={APC_NONE}, apc_handle=0000 }
0009:fixme:server:wait_select_reply cookie = 0x55555555
0009:fixme:server:wait_select_reply cookie = 0x55555555
--- snip ---

Those unexpected wakeup cookies are never removed again, and could overflow the wakeup pipe sooner or later.

The problem is caused when signalling and waiting on the same object. wait_on_handles(...) allocates the current->wait structure, but doesn't store a cookie yet. Afterwards the object is signalled, and wake_thread(...) is executed, which sends a wakeup cookie. This normally isn't necessary because we're still in the same wine server call, and the thread isn't waiting for any reply.

---
 server/thread.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-server-Avoid-sending-unexpected-wakeup-with-uninitia.patch
Type: text/x-patch
Size: 2424 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20141122/c57dcc61/attachment.bin>


More information about the wine-patches mailing list