STM32F303: Clock sporadically dies away
I see unconnected VDD, VDDA and VBAT pins in your circuit. You need to connect all those power pins to the chip.

VDDA might be the culprit here, as the crystal OSC might actually be powered by this pin.