BUG-HUNTING 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. [Sat Mar 2 10:32:33 PST 1996 KERNEL_BUG-HOWTO lm@sgi.com (Larry McVoy)]
  2. This is how to track down a bug if you know nothing about kernel hacking.
  3. It's a brute force approach but it works pretty well.
  4. You need:
  5. . A reproducible bug - it has to happen predictably (sorry)
  6. . All the kernel tar files from a revision that worked to the
  7. revision that doesn't
  8. You will then do:
  9. . Rebuild a revision that you believe works, install, and verify that.
  10. . Do a binary search over the kernels to figure out which one
  11. introduced the bug. I.e., suppose 1.3.28 didn't have the bug, but
  12. you know that 1.3.69 does. Pick a kernel in the middle and build
  13. that, like 1.3.50. Build & test; if it works, pick the mid point
  14. between .50 and .69, else the mid point between .28 and .50.
  15. . You'll narrow it down to the kernel that introduced the bug. You
  16. can probably do better than this but it gets tricky.
  17. . Narrow it down to a subdirectory
  18. - Copy kernel that works into "test". Let's say that 3.62 works,
  19. but 3.63 doesn't. So you diff -r those two kernels and come
  20. up with a list of directories that changed. For each of those
  21. directories:
  22. Copy the non-working directory next to the working directory
  23. as "dir.63".
  24. One directory at time, try moving the working directory to
  25. "dir.62" and mv dir.63 dir"time, try
  26. mv dir dir.62
  27. mv dir.63 dir
  28. find dir -name '*.[oa]' -print | xargs rm -f
  29. And then rebuild and retest. Assuming that all related
  30. changes were contained in the sub directory, this should
  31. isolate the change to a directory.
  32. Problems: changes in header files may have occurred; I've
  33. found in my case that they were self explanatory - you may
  34. or may not want to give up when that happens.
  35. . Narrow it down to a file
  36. - You can apply the same technique to each file in the directory,
  37. hoping that the changes in that file are self contained.
  38. . Narrow it down to a routine
  39. - You can take the old file and the new file and manually create
  40. a merged file that has
  41. #ifdef VER62
  42. routine()
  43. {
  44. ...
  45. }
  46. #else
  47. routine()
  48. {
  49. ...
  50. }
  51. #endif
  52. And then walk through that file, one routine at a time and
  53. prefix it with
  54. #define VER62
  55. /* both routines here */
  56. #undef VER62
  57. Then recompile, retest, move the ifdefs until you find the one
  58. that makes the difference.
  59. Finally, you take all the info that you have, kernel revisions, bug
  60. description, the extent to which you have narrowed it down, and pass
  61. that off to whomever you believe is the maintainer of that section.
  62. A post to linux.dev.kernel isn't such a bad idea if you've done some
  63. work to narrow it down.
  64. If you get it down to a routine, you'll probably get a fix in 24 hours.
  65. My apologies to Linus and the other kernel hackers for describing this
  66. brute force approach, it's hardly what a kernel hacker would do. However,
  67. it does work and it lets non-hackers help fix bugs. And it is cool
  68. because Linux snapshots will let you do this - something that you can't
  69. do with vendor supplied releases.