Fix Mach port leak in alt_clock_gettime on macOS#4840
Open
qingweizhang054 wants to merge 1 commit intozeromq:masterfrom
Open
Fix Mach port leak in alt_clock_gettime on macOS#4840qingweizhang054 wants to merge 1 commit intozeromq:masterfrom
alt_clock_gettime on macOS#4840qingweizhang054 wants to merge 1 commit intozeromq:masterfrom
Conversation
alt_clock_gettime on macOS
Author
|
Note: CI reports failures on the GitHub Actions macOS runner in I cannot reproduce this locally on macOS, and this PR does not modify any Relevant CI output: FAIL: tests/test_zmq_poll_fd FAIL: tests/test_zmq_ppoll_fd |
Author
|
This PR is ready for review when convenient. Thanks for your time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
This PR fixes a Mach port resource leak in the macOS implementation of
alt_clock_gettime.On macOS versions prior to 10.12 (Sierra, released in 2016),
clock_gettimeis not available, libzmq falls back toalt_clock_gettime, which uses Mach APIs to retrieve timing information. The current implementation callsmach_host_self()to obtain a host port, but does not release the associated send right after use.Since
mach_host_self()returns a send right that must be explicitly deallocated, repeated calls toalt_clock_gettimein long-running processes can lead to Mach port leaks and eventual resource exhaustion.This change ensures that the host port returned by
mach_host_self()is properly released viamach_port_deallocate()after use. The fix is limited to the legacy macOS code path and does not affect platforms that use the nativeclock_gettimeimplementation.Impact: