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

When you post things like that, you should include all the details. We understand technical things here. So instead of saying, "same values of R and C" you should specify the values.