Bug 32014 - HttpListener leaks sockets under load
Summary: HttpListener leaks sockets under load
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: 3.6.0
Hardware: Other Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-07-16 07:41 UTC by paul firth
Modified: 2015-07-16 07:41 UTC (History)
1 user (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
socket leak testbed (92.02 KB, application/x-zip-compressed)
2015-07-16 07:41 UTC, paul firth
Details

Description paul firth 2015-07-16 07:41:57 UTC
Created attachment 12065 [details]
socket leak testbed

HttpListener appears to be leaking sockets under heavy load. This shows up as an ever increasing number of 'can't identify protocol' entries from calling lsof | grep <pid>. Eventually, the process will run out of sockets completely, with them all being taken up by leaked sockets, which are not correctly closed by mono.

I've finally managed to create a minimal test bed to reproduce this problem, which I have attached to this report.

To use this testbed:

mono --debug server.exe

<new shell>

mono --debug client.exe

wait for around 10 seconds in the client shell, then press return to exit.

ps -A | grep mono

<locate server.exe pid>

lsof | grep <pid>

result:

...
mono       9160     root  mem       REG                8,1       6144    1576189 /root/socketDebug/server.exe
mono       9160     root    0u      CHR              136,0        0t0          3 /dev/pts/0
mono       9160     root    1u      CHR              136,0        0t0          3 /dev/pts/0
mono       9160     root    2u      CHR              136,0        0t0          3 /dev/pts/0
mono       9160     root    3u     IPv4          518804426        0t0        TCP localhost:webcache (LISTEN)
mono       9160     root    4u      REG                0,9          0       3674 anon_inode
mono       9160     root    5u     sock                0,6        0t0  518805101 can't identify protocol
mono       9160     root    6u     sock                0,6        0t0  518805103 can't identify protocol

Run the client again and watch the list of leaked sockets increase.

I have tried to look into the cause of this, and will continue to do so, but so far I haven't been able to identify the exact source of the leaks.

Cheers, Paul.

Note You need to log in before you can comment on or make changes to this bug.