Sudden, unexpected logouts
Sometimes, Yosemite will randomly log me out without warning or a chance to save work. This has happened twice so far since I've installed Yosemite on my 2012 Retina MacBook Pro. Needless to say, this is very unnerving and reminiscent of malware activity.
With help from Google and scouring event logs, I've traced the problem down to a crash in the window server. The crash report can be found here: http://puu.sh/csTor/0012220497.crash
Is there anything I can do to stop this from happening again?
Update: It seems having a secondary monitor is triggering it. Dell U2412 over HDMI. I also seem to be able to prevent crashing by avoiding the login screen while the monitor is plugged in.
There is no point in trying the vague 'catch all' solutions like wiping NVRAM and system controllers. The problem you are having is a SIGSEGV, or, a segmentation fault in WindowServer. It is likely due to corrupt identifiers. Those identifiers are stored in multiple places, and if enough get corrupt, you get crashes. While some identifiers are stored in the NVRAM (or PRAM), wiping this usually only postpones the next crash since the identifier eventually ends up in there again.
If WindowServer crashes, all GUI applications stop and it restarts via launchd. When WindowServer starts, it first gives you the login window. So in fact, you are not getting logged out, but your whole graphical session simply crashes.
Having a peek at your crash report, it seems this thread is crashing:
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
The last few calls were to color space functions (or methods), leading me to believe you might simply be dealing with a corrupt ICC profile.
The cash is within com.apple.CoreGraphics, and the most recent calls are to:
color_space_get_md5_digest + 57
color_space_get_identifier + 9
CGXColorSpaceRegistryCopyRegisteredColorSpace + 42
_CGXCopyColorSpace + 27
_XCopyColorSpace + 57
Now, if I'm right, it's trying to calculate the MD5 hash of a color space. It's doing that because it wants to find the identifier for a color space, and it needs that identifier because CGXColorSpaceRegistryCopyRegisteredColorSpace needs the color space data for the preset color profile for your monitor. Now, to be 100% this is the source of your crashes, I would need as many of your crash reports as possible, because if they all crash because of different reasons, it has nothing to do with the software on your system but it's more likely to be a hardware issue where bogus data is fed in to the software which then tries to do something with that data which it cannot do and therefore cashes.
A simple test might be to start Apple's built in ColorSync Utility and pressing the Repair button. This could print something like:
Header message digest (MD5) is not correct. Fixed.
Which would make sense since a broken MD5 might be the source of your crash. So try that first. On my system, that ColorSync Utility is in /Applications/Utilities and I think it has been there since every version of OS X. Please let me know if that found broken ICC files and if it could fix them. If not (either nothing found or unable to fix) please do post any crash logs on WindowServer you have :)
A possible cause for this could be invalid profiles generated by F.lux to provide smooth transitioning between GPU modes - here's an overview of what it does with these profiles: https://justgetflux.com/news/2014/10/28/profile.html
In my fresh install of El Capitan it had created these invalid profiles:
ColorSync Utility can be used to verify, remove and/or repair these profiles, or the flux profile switching can be completely disabled with:
defaults write org.herf.Flux disableProfile 1
Followed by removing the profiles.
This is a known Bug with Apple. I reported a similar problem in their bugtracker, which was closed as a duplicate of bug #18234875.
Sadly, those bugs cannot be viewed or tracked, apart by the reporter. However, it means that Apple knows about the problem and will hopefully fix it in one of the next OS X updates.