Corrupt User in OS X 10.12

I recently had my user account stop working properly.  Every time I logged in it would try to reset my login keychain; it repeatedly said 'the application '; I could not launch simple apps like Calculator and lots of other weirdness (e.g. my login did not have a fast user switcher).

Even more strangely, other users on the computer seemed unaffected, and my account on different computers seemed unaffected.  I tried deleting the user and recreating it, but got the same result.  It was like the computer didn't like my name!?

Digging into the error message after an application crash eventually lead to the solution.  The exact error was a problem validating the code signature of /usr/lib/libSystem.B.dylib.  Google showed at least one other person had this problem and was able to recover by replacing the file from another computer.  I didn't really want to do that - I don't like manually overwriting system files, and I had no idea how many other files needed replacing.  An alternative solution I found was to download and install the OS 'cumulative update' as this essentially overwrites all system files. 

 

This worked!  I had to manually rebuild my keychain - setting up dropbox and other apps again... but generally I now have a working computer again.  I have no idea how I managed to corrupt some system libraries, or why it only affected my user (some sort of malware launched on login?) 

Anyway, I'm posting this in the hope it helps someone else with a similar problem.   As of the time of writing the latest cumulative update is https://support.apple.com/kb/dl1897?locale=en_US, but no doubt newer updates will exist whenever people read this that would be more suitable.