Repo bisect
When testing reveals a bug, the cause of the bug can sometimes be found by searching the source repository. Git provides a tool (git-bisect
) to help search for which revisions caused some change. While you can use the tool by hand, it can also be automated.
Using bisect
For this project, you need to use x64 Linux. Download this project to get the bisector
repo. The repo has a single executable that seems to check TPU data values. If you run the most recent executable, you will see that it runs, but crashes.
We will use git to find the source code revision where the bug started. By marking revisions as good or bad, git will binary search the source tree to find the commit that caused the failure.
Finding the source
- Go to the
bisector
directory - To observe the bisection, run gitk with
gitk &
. Throughout this lab, you should check what is going on in the gitk window. Use Shift+F5 or File > Reload to see the marks you are making int the source tree. - Start bisection with
git bisect start
- Run the code. The most recent revision should crash. Mark this revision as 'bad' using
git bisect bad
- Get the SHA1 revision hash for the oldest revision and check it out. For example, it might be something like
git checkout c989
- Run the program. It should run to completion, so mark this revision as good:
git bisect good
- You can now begin the bisection in earnest, marking revisions as good or bad. Git will automatically checkout the next test version after each mark.
Questions
Complete the question sheet for this exercise.