Symptoms since using Mac OS X Lion (still relevant in the latest version of Lion: 10.7.5 released on 19 September 2012):

  • Your Mac starts feeling sluggish with some unexplained CPU usage
  • Your are unable to start any Application (even logout or restart as this needs to spawn a new process under the hood… your only chance is to switch user)
  • You are unable to open the Terminal or use certain commands in it:
    • id
    • sudo
    • whoami
  • You are no longer you (reported as User ‘????’ in Activity Monitor)
  • Your console is filled with message similar to this:
    • xpchelper[123]: getpwuid_r() failed for UID: 501, ret: 0, errno: 0

If you search the web for the above, you will see that you are not alone having this problem…

Activity Monitor showing higher than usual CPU usage. Note that the sum of highest % CPU Processes is less than the reported % User and % System combined.

Oh my God!!! Terminal won’t even start!

No wonder your Mac is slow… Look at the rate of logging in the Console application! One pid gets created every 20 ms on my MacBook…

So, what is the way to deal with this until Apple issues a fix in a future update (this bug seems to have been fixed since Mac OS X Mountain Lion 10.8)?

Well, if you had Activity Monitor or a Terminal running before the problem occurred, you can simply quit the process named opendirectoryd (it will be automatically restarted by launchd) and then magically, your Mac will behave normally again.

Alternatively, switch user to kill opendirectoryd from the new session with administrative rights.

Quit / Force Quit opendirectoryd from the list to get back to normal…

There you go, %CPU back to normal, opendirectoryd automatically restarted, your Mac is now back to normal.