What happens if a reviewer finds a fatal flaw in a proof in one's mathematical PhD thesis?

I'm aware of a thesis that unravelled at the oral defense: one examiner found a small error and it turned into a big error that invalided a substantial part of the thesis. The candidate was required to make major revisions. (The party scheduled after the defense was promptly cancelled.)

I'm also aware of a thesis that was downright rejected by the external examiner before it reached the oral defense stage. The candidate also has to make major revisions.

These occurrences are very rare: most programs have various milestones to satisfy before a thesis can be submitted, and these roadbumps are there precisely to avoid this kind of mess (which makes everybody look bad, especially the supervisor and the supervisory committee.) It's rare but it does happen, and on both occasions the candidate dug in, cleaned up the work, resubmitted some months after and eventually graduated.

(One thesis was in physics, the other in math.)