Structural and chemical stability of halide perovskites