I was in my 6th year. All my friends had graduated, and my stipend had run out. I was 2 weeks away from submission and discovered that one of my assumptions was wrong, which potentially distorted/invalidated all my studies -- to fix these studies would have potentially delayed submission for months. It was a very subtle assumption violation (and it wasn't even that wrong) and my committee probably wouldn't even have noticed. I was tempted to sweep it under the carpet and not let it keep me from graduating.
But I knew it was wrong. I felt that if I sacrificed my integrity then, the moral failure would mark me for life. No one would know -- but I would know. So I decided to fix the issue, re-do the studies and live with the reality that I would have to delay my defense.
Turns out when you're desperate -- and many grad students can attest to this -- a resourcefulness that you never thought you had kicks in ("where were you during all my years of grad school?"). I don't remember how, but I somehow managed to wrangle new studies out in 3 days (which would have previously taken me months). I made the deadline in the end.
The lesson I learned was that committing to doing the right thing has its costs, but in some cases it also forces one to explore attacks never previously considered. Asking on MathOverflow is one such attack.