Skip to content

Fix user client leak: terminate instance on clientClose - #194

Closed
totemofwolf wants to merge 1 commit into
trulyspinach:masterfrom
totemofwolf:fix-userclient-leak
Closed

totemofwolf wants to merge 1 commit into
trulyspinach:masterfrom
totemofwolf:fix-userclient-leak

Conversation

@totemofwolf

Copy link
Copy Markdown

Problem

AMDRyzenCPUPMUserClient never implements clientClose(). The default IOUserClient::clientClose returns kIOReturnUnsupported, so the connection object is never terminated — every IOServiceOpen/close cycle (or every client process exit) leaks one user client instance.

Once enough instances pile up, the provider stops accepting new clients and IOServiceOpen fails permanently for every process until reboot.

Observed in the wild

Polling a status CLI every 2 seconds for ~35 minutes accumulated 1000+ zombie AMDRyzenCPUPMUserClient instances under a single provider (visible via ioreg -rc AMDRyzenCPUPMUserClient), after which IOServiceOpen failed for all processes. Only a reboot clears them.

Fix

Implement clientClose() the canonical way: terminate() the instance and return kIOReturnSuccess. stop() already cleans up fProvider.

Testing

  • Lenovo Legion R7000P 2021 (Ryzen 7 5800H), macOS Ventura 13.7.8, OpenCore
  • Repeated open/close cycles no longer accumulate instances in ioreg

AMDRyzenCPUPMUserClient never implemented clientClose, so the default
IOUserClient::clientClose (kIOReturnUnsupported) left every instance
alive after the connection closed or the client process exited.
Opening/closing the connection repeatedly (e.g. status polling every 2s)
accumulated dead user clients until IOServiceOpen failed permanently
(observed: 1000+ zombies under one provider after ~35 minutes of
2-second polling).

Implement clientClose() to terminate the instance, matching the
canonical IOUserClient pattern.
@trulyspinach

Copy link
Copy Markdown
Owner

I need to hear your reasoning and review of the code. Not from AIs.

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.

2 participants