This happens to me randomly when I resume from standby (ie opening my laptop). A log out or reboot is the only way for me to fix it. I dont know exactly what causes it. As I type it is happening right now. As the comment in the original post asked, I ran id -p and it crashed. (Crash report: http://pastebin.com/nmFFQELq)
whoami - returns 501
id -p - crashes
cat /etc/passwd - my user is not in the document.
any ssh attempt fails with the error: You don't exist, go away!
I also checked out the console, from waking up, a bunch of random "Socket not connected" errors appear (which I think might be normal, being that wireless doesnt connect immediately) from programs like dropbox. An interesting error appears though:
4/12/12 8:37:09.045 PM coreservicesd: _scserver_ServerCheckin: client uid validation failure; getpwuid(501) == NULL
4/12/12 8:37:09.400 PM coreservicesd: _scserver_ServerCheckin: client uid validation failure; getpwuid(501) == NULL
Still not sure what is causing it, but thought I would share these diagnostics.
Im on a Mid 2009 MacBook Pro with 10.7.3 installed