Skip to content

Fix Mach port leak in alt_clock_gettime for macOS#4839

Closed
qingweizhang054 wants to merge 1 commit intozeromq:masterfrom
qingweizhang054:dev3
Closed

Fix Mach port leak in alt_clock_gettime for macOS#4839
qingweizhang054 wants to merge 1 commit intozeromq:masterfrom
qingweizhang054:dev3

Conversation

@qingweizhang054
Copy link

Title: Fix Mach port leak in alt_clock_gettime for macOS

Description:
While reviewing the clock implementation for macOS (legacy versions < 10.12), I noticed a Mach port leak in alt_clock_gettime.

According to Mach kernel documentation, mach_host_self() returns a send right to the host's port which increments the port's reference count. This right must be released using mach_port_deallocate to prevent resource exhaustion in long-running processes.

Changes:

  • Store the result of mach_host_self() in a local variable.
  • Call mach_port_deallocate for the host port after obtaining the clock service.

Impact:

  • Fixes a slow resource leak on macOS legacy systems.
  • No impact on modern macOS (10.12+) as they use the native clock_gettime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant