What triggers safe-mode? While reading through the bitcoin wiki I found this following segment describing a bitcoin RPC safe-mode


  Until version 0.3.20, Bitcoin went into safe mode when a valid alert
  was received. In safe mode, all RPC commands that send BTC or get info
  about received BTC return an error. Current Bitcoin versions no longer
  go into safe mode in response to alerts, though Bitcoin will still go
  into safe mode when it detects on its own that something is seriously
  wrong with the network.
  
  Even though Bitcoin no longer automatically disables RPC when an alert
  is live, it is wise for Bitcoin sites to shut down when an alert has
  been issued. To detect an active alert, poll the "errors" field of
  getinfo.
  
  To test safe mode, run Bitcoin with the -testsafemode switch. To
  override a real safe mode event, run Bitcoin with the -disablesafemode
  switch.
  
  https://en.bitcoin.it/wiki/Alerts#Safe_mode


It says "Bitcoin will still go into safe mode when it detects on its own that something is seriously wrong with the network." I am interested in learning which events would make bitcoin go in to safe mode on it's own.
It looks like the relevant code is in CheckForWarningConditions().  This sets the flags fLargeWorkForkFound and fLargeWorkInvalidChainFound, which are checked by GetWarnings(), which is called in CRPCTable::execute() to check if safe mode should be enforced.

It appears that the code looks for large forks in the block chain, suggesting that miners disagree on which blocks are valid.  The two flags seem to correspond to which camp our client falls in.