Microcontroller freezes randomly when switching on a relay (snubber inside)

When I read that, I took it to mean that it would be easy to improve.