https://bugs.winehq.org/show_bug.cgi?id=38143
Bug ID: 38143 Summary: IO completions cause wineserver to leak APC packets Product: Wine Version: 1.7.37 Hardware: x86 OS: Linux Status: NEW Severity: normal Priority: P2 Component: -unknown Assignee: wine-bugs@winehq.org Reporter: dmitry@baikal.ru Distribution: ---
Created attachment 50870 --> https://bugs.winehq.org/attachment.cgi?id=50870 leaky io ports application
This started as a report that after long time execution (couple of days) wineserver memory usage grows by tens hundreds of megabytes.
Attached is a simple .net application (with source) that demonstrates the problem. Steps to reproduce: 1. rm -rf ~/.wine 2. winetricks -q dotnet40 3. wine IOPortsLeakyApp.exe
And in a separate terminal watch how wineserver heap usage starts to very quickly grow: pmap -X -p `pidof wineserver` | grep heap
The source of the leak is at server/async.c,async_set_result(), a queued thread APC packet is never fetched from the queue and as a result is never executed and freed.
The problem is that an APC packet is added to queue as APC_USER type and that needs an alterable thread wait, otherwise server/thread.c,select() handler (actually thread_dequeue_apc(), but that's minor detail) will fetch only system APCs and never user ones.
One solution would be to put a thread into alertable wait so it has an opportunity to handle user APCs, another is to add an IO completion APC to the system instead of user APC queue.