Is a safety pilot required to share costs?
This actually came up in chat recently -- the answer (if only the two pilots are on board) is a qualified "No", not because the time isn't "compensation" but because the safety pilot is a required crewmember for simulated instrument flight.
Since both pilots are required crewmembers the safety pilot is not acting as a PIC of a flight carrying passengers as long as they are only acting as the Legal PIC while the other pilot is under the hood.
(Note however that while neither pilot is in simulated instrument conditions the safety pilot is not required crew, and therefore someone is PIC of a flight carrying at least one passenger - so log your time carefully and try to wrap your head around a "pro rata share" of that mess.)

This is further addressed (more directly) in the interpretation issued to Roberts, July 11, 2012.



Note that if we're talking about a flight with more than the two pilots on board (carrying someone who is NOT a required crewmember, like a friend in the back seat) then the whole thing goes out the window: No matter who is acting as the Legal PIC for the flight they're "PIC of a flight carrying passengers", and you're back to pro rata share territory.