A Practical Taxonomy of Bugs and How to Squash Them-SunshinePHP

2ed277a8bb1cc68c943fd84f3ce32782?s=47 Kylie
February 03, 2017

A Practical Taxonomy of Bugs and How to Squash Them-SunshinePHP

Review my talk and give me feedback: https://joind.in/talk/3f670
Catching software bugs is a mysterious magic, unknowable by science and untouchable by process.

False! Programming bugs, like real bugs, can be organized into a taxonomy. Come with me and I'll show you how classification can help you build “programmer’s instinct” into a logical debugging process.

Debugging may be instinctual but those instincts come from seeing, identifying and diagnosing patterns. In this talk, we’ll use phenetic taxonomy to build a debugging decision making network based on attributes and behaviors of common bugs. Newer developers will learn how to apply systematic pattern matching to debugging while seasoned developers will learn how to use their instincts to teach debugging.

2ed277a8bb1cc68c943fd84f3ce32782?s=128

Kylie

February 03, 2017
Tweet

Transcript

  1. A PRACTICAL TAXONOMY OF BUGS AND HOW TO SQUASH THEM

    https://joind.in/talk/3f670
  2. Instinctual Indications…6 Research Methods…9 Practical Taxonomy…13 Bohrbug…17 Schrödinbug…25 Fractalbug…24 Heisenbug…35

    Mandelbug…44 Resources…55 Table of Contents
  3. Debugging Skills

  4. “As you familiarize yourself with the application, you’ll build up

    some debugging instincts"
  5. “Whenever I see something like this happening, the first thing

    I do is scan the logs to see if this process is completing or is sending a weird message.”
  6. None
  7. Debugging Instincts “ ”

  8. None
  9. None
  10. “Whenever I see #{x}, I always check #{y}”

  11. Instincts are just internalized rulesets

  12. Research Methods • containment sometimes takes priority over squashing •

    we can only work with facts • we can’t squash every bug in this talk
  13. Observable Attributes

  14. Phenetics { ]

  15. Warning: Contrived Scenarios Ahead

  16. A PRACTICAL TAXONOMY OF BUGS AND HOW TO SQUASH THEM

  17. A Practical Taxonomy of Bugs Upsettingly Observable Wildly Chaotic {

  18. Upsettingly Observable Bugs

  19. Wildly Chaotic Bugs

  20. How to Squash Them

  21. upsettingly observable bug #1 UPSETTINGLY OBSERVABLE

  22. Observable Attributes is the bug observable in production?

  23. Observable Attributes is the bug observable in production? can it

    be reproduced locally?
  24. Observable Attributes is the bug observable in production? can it

    be reproduced locally? does it seem to be restricted to one area?
  25. Bohrbug deterministic, highly reproducible UPSETTINGLY OBSERVABLE

  26. Bohrbug Commonly found in code,sometimes on server UPSETTINGLY OBSERVABLE

  27. Bohrbug likes to hide in complex branching in functions, classes

    or config UPSETTINGLY OBSERVABLE
  28. Bohrbug In the wild: validation UPSETTINGLY OBSERVABLE

  29. Bohrbug UPSETTINGLY OBSERVABLE Easy to squash

  30. Reproduction & Resolution replicate locally and in test UPSETTINGLY OBSERVABLE

  31. Reproduction & Resolution replicate locally and in test write the

    simple solution UPSETTINGLY OBSERVABLE
  32. Reproduction & Resolution replicate locally and in test write the

    simple solution rewrite to be highly readable and extendable UPSETTINGLY OBSERVABLE
  33. Bohrbug UPSETTINGLY OBSERVABLE

  34. upsettingly observable bug #2 UPSETTINGLY OBSERVABLE

  35. Observable Attributes how does this work?

  36. Observable Attributes how does this work? does this work?

  37. Observable Attributes how does this work? does this work? wait,

    what is this even testing?
  38. Observable Attributes how does this work? does this work? wait,

    what is this even testing? did this ever work?
  39. Schrödinbug stick-like body appendages look like twigs UPSETTINGLY OBSERVABLE

  40. Schrödinbug Likes to pretend to be working code. On close

    inspection, reveals itself to be a bug. UPSETTINGLY OBSERVABLE
  41. Schrödinbug UPSETTINGLY OBSERVABLE Type I. Type II.

  42. Schrödinbug Type I. Code that never worked UPSETTINGLY OBSERVABLE

  43. Schrödinbug Type I. Reveal themselves via side-effects UPSETTINGLY OBSERVABLE

  44. Schrödinbug Type I. In the wild: UI shows update but

    database entry not updated. UPSETTINGLY OBSERVABLE
  45. Schrödinbug Type II. Code that doesn’t work how you thought

    UPSETTINGLY OBSERVABLE
  46. Schrödinbug Type II. In the wild: Same function being called

    multiple times UPSETTINGLY OBSERVABLE
  47. Basic Reproduction & Resolution replicate locally and in test write

    the simple solution rewrite to be highly readable and extendable UPSETTINGLY OBSERVABLE
  48. -You “How can I reproduce this without knowing exactly what

    is happening?”
  49. Logging as Verification Tool

  50. Git Bisect Tool

  51. Reproduction & Resolution reproduce the “broken” state locally and in

    test
  52. Reproduction & Resolution reproduce the “broken” state locally and in

    test add log statements until you can verify what causes the broken state.
  53. Reproduction & Resolution reproduce the “broken” state locally and in

    test add log statements until you can verify what causes the broken state. if the bug did work at some point, find the point at which it did work.
  54. Reproduction & Resolution reproduce the “broken” state locally and in

    test add log statements until you can verify what causes the broken state. if the bug did work at some point, find the point at which it did work. write tests to represent the configuration and flow of the fixed state
  55. Schrödinbug UPSETTINGLY OBSERVABLE

  56. wildly chaotic bug #1 WILDLY CHAOTIC

  57. Observable Attributes Does it appear non-deterministic?

  58. Observable Attributes Does it appear non-deterministic? Does it seem to

    disappear once you observe or debug it?
  59. Heisenbug “now you see it, now you don’t” WILDLY CHAOTIC

  60. Heisenbug WILDLY CHAOTIC Type I. Type II.

  61. Heisenbug Type I. WILDLY CHAOTIC Lives in code

  62. Heisenbug Type II. WILDLY CHAOTIC Lives in data

  63. -You “How can I reproduce this without testing on production?”

  64. Profiling for Verification https://kcachegrind.github.io/html/CallgrindFormat.html Tool

  65. FLAME GRAPHS http://www.brendangregg.com/FlameGraphs/cpu-mysql-updated.svg Tool

  66. Reproduction & Resolution use profiling to find the trigger state

  67. Reproduction & Resolution use profiling to find the trigger state

    use the app (not fixtures or DB manipulation) to get the data in this state
  68. Reproduction & Resolution use profiling to find the trigger state

    use the app (not fixtures or DB manipulation) to get the data in this state recreate that state in test
  69. Reproduction & Resolution use profiling to find the trigger state

    use the app (not fixtures or DB manipulation) to get the data in this state recreate that state in test follow borhbug instruction
  70. Heisenbug WILDLY CHAOTIC

  71. wildly chaotic bug #2 WILDLY CHAOTIC

  72. Observable Attributes is everything broken?

  73. Observable Attributes is everything broken? all of it?

  74. Observable Attributes is everything broken? all of it? send help??

  75. Mandelbug WILDLY CHAOTIC

  76. Mandelbug seems like everything is broken at once WILDLY CHAOTIC

  77. Mandelbug people are very upset with you WILDLY CHAOTIC

  78. Mandelbug likely an issue with your system, not code WILDLY

    CHAOTIC
  79. “The bug is huge and everywhere at once. SQL: could

    not connect to server: Connection refused was bubbling up all over the place. Jobs won’t run, emails won’t send, every submit button on the site fatal errored.” on-call log WILDLY CHAOTIC
  80. Disk Usage Tool df -h

  81. Logging as Verification Tool

  82. Reproduction & Resolution use df -h to find if all

    the storage is being use
  83. Reproduction & Resolution use df -h to find if all

    the storage is being use attempt to connect to server & view logs
  84. Reproduction & Resolution use df -h to find if all

    the storage is being used attempt to connect to server & view logs can that be restarted, rotated or killed at this time?
  85. Mandelbug WILDLY CHAOTIC

  86. A Practical Taxonomy of Bugs Upsettingly Observable Wildly Chaotic {

    bohrbug schrödinbug mandelbug heisenbug
  87. “Debugging Instincts”

  88. Debugging Skills

  89. Observe & Classify

  90. Verify with logging and time travel

  91. Verify without changing state by profiling

  92. Use server tools to observe entire process

  93. Observe & Classify Verify with logging and time travel Verify

    without changing state by profiling Use server tools to observe entire process
  94. Build Up Your Own Toolkit and Share it

  95. Resources & Further Study • “Linux Debugging Tools I Love”,

    Julia Evans • Systems Performance, Brendan Gregg • “Why Do Computers Stop and What Can Be Done About It?”, Jim Gray • “Debug Patterns for Efficient High- levelSystemC Debugging”, Frank Rogin, Erhard Fehlauer, Christian Haufe, Sebastian Ohnewald
  96. https://joind.in/talk/3f670