Log in

No account? Create an account
Entries Friends Calendar User Info ByersWorks Previous Previous Next Next
The Joy of Programming... - Unbeliever's Land
...The continuing chronicles...
The Joy of Programming...
At work, I've been working on this new web form to allow OSU student advisors to enter Substitutions and Waivers for students online. I've never done anything remotely this complex on the web, and I've been forced to learn much of what's been needed as I go.

Today, though, I ran into one of those problems that, quite simply, is impossible.

I have two similar items I have to validate -- lets call them "A" and "B".

In both cases, they might be 1) Already correct, 2) Incorrect, but fixable, or 3) Unfixable. In the third case, I return a polite error message to the user.

The code simply checks "A" for each of these cases, and if it's correct or fixable, it moves on and checks "B". The code is IDENTICAL for both "A" and "B".

Now for the fun part.
  • If both items are correct, I have no problem.
  • If both items are fixable, I have no problem.
  • If both items are unfixable, I have no problem.
  • If "A" is correct and "B" is fixable, I have no problem.
  • If "A" is correct and "B" is unfixable, I have no problem.
  • If "A" is unfixable (it doesn't matter what "B" is, since I stop and give the error for "A"), I have no problem.
  • If "A" is fixable and "B" is correct, I have no problem.

  • *BUT*

  • If "A" is fixable, and "B" is unfixable, in ONLY THAT INSTANCE -- the page crashes. Utterly. [And without anything even remotely resembling a useful error message.]
What makes this more puzzling, it that it crashes WHILE PROCESSING "A" -- before it even knows the state of "B". Yet if "B" had been in the "correct" or "fixable" state, the page wouldn't have crashed.

I spent three hours testing this, putting in all the debugging statements I could, trying to track the problem. I checked for typos, using the wrong variables, etc. The code in question is not that long. But I proved beyond any doubt that the crash ONLY occurred when "A" was fixable and "B" was unfixable -- and that the crash was specifically during the fixing of "A", before the state of "B" was determined. In any other condition, when either "A", "B" or both are fixable, they get fixed with no problem.

By the end of the day, I finally found a kluge to prevent the problem, involving some indirection, copying "A" and "B" to other variables of a slightly different type and doing the work on THOSE variables. But the mystery remains -- since the original code was perfectly capable of fixing "A" and "B", both independently and together, why did "B" being unfixable, cause "A" to crash when it was being fixed?

Welcome to the lunatic asylum...

Current Emotional State: frustrated frustrated

Write comment