Skip to content

Fix memory leak in Windows networking subsystem#5096

Merged
SeanTAllen merged 1 commit intomainfrom
fix-iocp-writev-send-leak
Apr 1, 2026
Merged

Fix memory leak in Windows networking subsystem#5096
SeanTAllen merged 1 commit intomainfrom
fix-iocp-writev-send-leak

Conversation

@SeanTAllen
Copy link
Copy Markdown
Member

Both pony_os_writev and pony_os_send allocate an iocp_t via iocp_create before calling WSASend. If WSASend fails with WSAEWOULDBLOCK, the functions returned without calling iocp_destroy, leaking the allocation and permanently elevating the IOCP token's refcount. Over time this could cause unbounded memory growth.

The fix adds the missing iocp_destroy(iocp) call to the WSAEWOULDBLOCK case in both functions, matching the cleanup already done in the default error case.

Closes #5090

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
@SeanTAllen SeanTAllen added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label Apr 1, 2026
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Apr 1, 2026
@SeanTAllen
Copy link
Copy Markdown
Member Author

ad-hoc stress test run: https://github.com/ponylang/ponyc/actions/runs/23865002258

@SeanTAllen SeanTAllen merged commit fb175fb into main Apr 1, 2026
19 checks passed
@SeanTAllen SeanTAllen deleted the fix-iocp-writev-send-leak branch April 1, 2026 19:44
@ponylang-main ponylang-main removed the discuss during sync Should be discussed during an upcoming sync label Apr 1, 2026
github-actions bot pushed a commit that referenced this pull request Apr 1, 2026
github-actions bot pushed a commit that referenced this pull request Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IOCP token refcount leak in pony_os_writev and pony_os_send on WSAEWOULDBLOCK

2 participants