The Art and Science of Debugging DCBPW Debugging Intro... · • Log::Dispatch • Framework ......
195
The Art and Science of Debugging PPW 2011 Brock Wilcox [email protected]
The Art and Science of Debugging DCBPW Debugging Intro... · • Log::Dispatch • Framework ... ERROR: Date not set in obj. HOWEVER: Date IS set in DB! ... Fix mod_deflate issue
Revision control back to 2002(RT comments since 2007)
Debugging
Bug?
Undesired Behavior?
Developer vs Operations
My arbitraryprocess breakdown
Report
ReportReproduce
ReportReproduceReduce
ReportReproduceReduceComprehend
ReportReproduceReduceComprehendCorrect
ReportReproduceReduceComprehendCorrectPrevent
I call this therrrccp bugfix cycle.
r3c2p
(not really)
ReproduceDiagnoseFixReflect
ReportReproduceReduceComprehendCorrectPrevent
Most important:
Reproduce
This talk:
Reduce / Comprehend
ReportReproduceReduceComprehendCorrectPrevent
Report Quality
"The program doesn't work"
Gee, thanks.
Good reports answer these:
• How is it working now?• How is it supposed to work?
Good reporters collect these:
• What are you trying to achieve?• Is this one issue or many?• Is this a code issue?• When did the issue start?• How often does it occur?• Is it reliably reproducable?• Are there test-steps?• Screenshot / Screencast?• Is there a work-around
Help your bug-reportersto report bugs better.
ReportReproduceReduceComprehendCorrectPrevent
Ship in a Bottle
You do have a test environment, right?
State
The biggest enemy:
Non-determinism.
State before,Execute test,State after
ReportReproduceReduceComprehendCorrectPrevent
Shrink That Ship, Yo
If you discover the essence of the problem,enlightenment will follow.
Autmated test failing:• Import file• Get obj from DB• Verify obj (FAIL)
ERROR: Date not set in obj
HOWEVER: Date IS set in DB!
Wha?
Hint:• Import file•• Using ORM• Get obj from DB•• Using ORM• Verify obj
How does the date get into the DB?
Trace w/ SQL Log
Auto-set on insert by ORM
... but not copied back to obj!
This is why you shouldn'twrite your own ORM.
Other Tips
Error Seeding
Verify Assumptions
Is that variable still thevariable that you think it is?
say "obj: $obj\n";
Compiler help
Change one variable at a time
Watch for edge cases
Especiall off-by-one
And type-o
Nondeterminism can be causedby resource consumption
ReportReproduceReduceComprehendCorrectPrevent
You know, enlightenment and stuff.
Types of bugs
"Programming Bug"
Code does not do what you intended.
"Logic Bug"
It's doing exactly what you wanted it to.
"Timing Bug"
(aka: concurrency bug)
One of the worst bugs ever!
Things I hear
I ran into this impossible situation...
Clearly it isn't.
Given so much time, the "impossible"becomes possible, the possible probable,and the probable virtually certain.One has only to wait: time itselfperforms the miracles.
-- George Wald
Vizzini:HE DIDN'T FALL? INCONCEIVABLE.
Inigo Montoya:You keep using that word. I do not thinkit means what you think it means.