Skip to content

Commit fb175fb

Browse files
authored
Fix memory leak in Windows networking subsystem (#5096)
The WSAEWOULDBLOCK case in pony_os_writev and pony_os_send returned without calling iocp_destroy, leaking the iocp_t and permanently elevating the token's refcount. Closes #5090
1 parent c66d269 commit fb175fb

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Fix memory leak in Windows networking subsystem
2+
3+
Fixed a memory leak on Windows where an IOCP token's reference count was not decremented when a network send operation encountered backpressure. Over time, this could cause memory to grow unboundedly in programs with sustained network traffic.

src/libponyrt/lang/socket.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,7 @@ PONY_API size_t pony_os_writev(asio_event_t* ev, LPWSABUF wsa, int wsacnt)
986986
case WSA_IO_PENDING:
987987
return wsacnt;
988988
case WSAEWOULDBLOCK :
989+
iocp_destroy(iocp);
989990
return 0;
990991
default:
991992
iocp_destroy(iocp);
@@ -1031,6 +1032,7 @@ PONY_API size_t pony_os_send(asio_event_t* ev, const char* buf, size_t len)
10311032
case WSA_IO_PENDING:
10321033
return len;
10331034
case WSAEWOULDBLOCK :
1035+
iocp_destroy(iocp);
10341036
return 0;
10351037
default:
10361038
iocp_destroy(iocp);

0 commit comments

Comments
 (0)