Safety of stochastic systems: An analytic and computational approach