|
|
Subscribe / Log in / New account

Development

Fully automated bisecting with "git bisect run"

February 3, 2009

This article was contributed by Christian Couder

It's a common developer practice to track down a bug by looking for the change that introduced it. This is most efficiently done by performing a binary search between the last known working commit and the first known broken commit in the commit history. git bisect is a feature of the Git version control system that helps developers do just that.

git bisect may also be well known by LWN readers for heated discussions on the Linux kernel mailing list about "asking" (or "forcing" depending on the point of view) users to find the bad commit when they report a regression. But a little-known addition, git bisect run, can allow a developer to completely automate the process. This can be very useful and may enable switching to interesting new debugging workflows.

At each step of the binary search, git bisect checks out the source code at the commit chosen by the search. The user then has to test to see if the software is working or not. If it is, the user performs a git bisect good, otherwise they do a git bisect bad, and the search proceeds accordingly. This is different than the idea behind git bisect run, as it uses a script or a shell command to determine if the source code—which git bisect automatically checked out—is "good" or "bad".

This idea was suggested by Bill Lear in March 2007, and I implemented it shortly thereafter. It was then released in Git 1.5.1.

Technically, the script or command passed to git bisect run is run at each step of the bisection process, and its exit code is interpreted as "good", if it's 0, or "bad", otherwise (except 125 and values greater than 127, see the git bisect documentation for more information.)

One simple and yet useful way to take advantage of that is to use git bisect run to find which commit broke the build. Some kernel developers like this very much. Ingo Molnar wrote:

for example git-bisect was godsent. I remember that years ago bisection of a bug was a very [laborious] task so that it was only used as a final, last-ditch approach for really nasty bugs. Today we can [autonomously] bisect build bugs via a simple shell command around "git-bisect run", without any human interaction!

For example, with a not too old Git (version 1.5.2 or greater), bisecting a build bug in the Linux kernel may be just a matter of launching:

    git bisect start linux-next/master v2.6.26-rc8
    git bisect run make kernel/fork.o

because the git bisect start command, when it is passed two (or more) revisions, here "linux-next/master" and "v2.6.26-rc8", interprets the first one as "bad" and the other ones as "good".

This works as follows: git bisect checks out the source code of a commit to be tested, then runs make kernel/fork.o. make will exit with code 0 if it builds, or with something else (usually 2) otherwise. This gets recorded as "good" or "bad" for the commit that was checked out, which will enable the binary search to continue by finding another commit to check out, then run make again, and so on, until the first "bad" commit in the history is found.

But to bisect regressions that manifest themselves on the running code, as opposed to build problems, it's usually more complicated. You probably have to write a test script that should be passed to git bisect run.

For example, a test script for an application built with make and printing on its standard output might look like this:

    #!/bin/sh

    make || exit 125   # an exit code of 125 asks "git bisect"
		       # to "skip" the current commit

    # run the application and check that it produces good output
    ./my_app arg1 arg2 | grep 'my good output'

See this message from Junio Hamano, the Git maintainer, for explanations and a real world example of git bisect run used to find a regression in Git. The git bisect documentation has some short examples too.

It's even trickier for kernel hackers, because you have to reboot the computer each time you want to test a new kernel, but some kernel hackers suggest that it be used anyway if the problem is "reproducible, scriptable, and you have a second box". Ingo Molnar describes his bisection environment this way:

i have a fully automated bootup-hang bisection script. It is based on "git-bisect run". I run the script, it builds and boots kernels fully automatically, and when the bootup fails (the script notices that via the serial log, which it continuously watches - or via a timeout, if the system does not come up within 10 minutes it's a "bad" kernel), the script raises my attention via a beep and i power cycle the test box. (yeah, i should make use of a managed power outlet to 100% automate it)

So it's possible to use git bisect run on a wide array of applications. This means that, for example, automatically in your nightly builds, you can find the commit that broke the build or the test suite, and then use information from it to send a flame warning email to the developer responsible for that.

But what may be more interesting is that fully automated bisection may enable new workflows. On the git mailing list, Andreas Ericsson, a Git developer, reported:

To me, I'd happily use any scm in the world, so long as it has git-bisect. Otoh, I'm a lazy bastard and love bisect so much that all our automated tests are focused around "git bisect run". This means bugs in software released to customers are few and far apart. When we get one reported, we just create a new test that exposes it, fire up git-bisect and then go to lunch. Quality costs, however. We pay that bill by using a workflow that's perhaps more convoluted than necessary.

So it requires a little more work to make sure that every commit is small and easily bisectable. Then, to debug regressions, they follow these steps:

  • write, in the test suite, a test script that exposes the regression
  • use git bisect run to find the commit that introduced it
  • fix the bug that is often made obvious by the previous step
  • commit both the fix and the test script (and if needed more tests)

This may seem more complicated than a traditional workflow. But when asked about it, Andreas says:

I guess the real benefit is that "git bisect" makes the tests so immensely valuable, and so easy to write, that we do it gladly and quickly. The value comes *now* from almost all test-cases instead of in some far-distant and obscure future.

So this kind of workflow is good to take advantage of test cases you write. But what about global productivity? Four months after having said that he uses git bisect run, Andreas Ericsson wrote that git bisect "is well-nigh single-handedly responsible for reducing our average bugreport-to-fix time from 4 days to 6 hours".

Now, after more than one year of using it, he gives the following details:

To give some hard figures, we used to have an average report-to-fix cycle of 142.6 hours (according to our somewhat weird bug-tracker which just measures wall-clock time). Since we moved to git, we've lowered that to 16.2 hours. Primarily because we can stay on top of the bugfixing now, and because everyone's jockeying to get to fix bugs (we're quite proud of how lazy we are to let git find the bugs for us). Each new release results in ~40% fewer bugs (almost certainly due to how we now feel about writing tests). That's a huge boost in code quality and productivity, and it earned me and my co-workers a rather nice bonus last year :)

So quality costs, but, when using the right tools and workflows, it can bring in a rather nice return on investment!

Comments (15 posted)

System Applications

Clusters and Grids

rsplib 2.6.0 released

Version 2.6.0 of rsplib has been announced. "RSPLIB is the Open Source implementation (GPLv3) of the IETF's new standard for Reliable Server Pooling (RSerPool), which is described in RFC 5351 to RFC 5356. If you a looking for a Grid comput[at]ion solution which is simple, easy to setup and mostly self-configuring, you are probably looking for RSerPool".

Full Story (comments: none)

Database Software

CrunchyFrog 0.3.2 released

Version 0.3.2 of CrunchyFrog has been announced, it adds some new functionality and bug fixes. "CrunchyFrog is a database navigator and SQL client. Currently PostgreSQL, MySQL, Oracle, SQLite3, MS-SQL databases and LDAP servers are supported for browsing and querying. More databases and features can be added using the plugin system. CrunchyFrog is licensed under the GPLv3 and is written in Python and uses PyGTK for it's user interface."

Full Story (comments: none)

pgAdmin gets a change of licence

The pgAdmin project will undergo a change of license. "Effective from the 26th February 2009, the pgAdmin Development Team intend to change the licence of pgAdmin III from the Artistic Licence v1.0 to the Artistic Licence v2.0".

Full Story (comments: none)

PostgreSQL Weekly News

The February 1, 2009 edition of the PostgreSQL Weekly News is online with the latest PostgreSQL DBMS articles and resources.

Full Story (comments: none)

Interoperability

Samba 3.2.8 maintenance release is available

Maintenance Release 3.2.8 of Samba has been announced. "This is the latest bug fix release for Samba 3.2 and is the version recommended for all production Samba servers running this release series."

Comments (none posted)

Security

dradis version 2.0 released

Version 2.0 of dradis has been released. "- dradis is an open source tool for sharing information during security assessments. - It provides a centralized repository of information to keep track of what has been done so far, and what is still ahead. - Client/server architecture with a web interface ".

Full Story (comments: none)

Web Site Development

Zope 3.4.0 Released

After two years of development, Zope 3.4, a Python-based web application server, has been released. In the future, releases are planned for every six months. "The focus of the Zope 3.4 development effort has been the conversion from a monolithic source tree, to a set of many small packages (eggs), that can be used independently of each other. The core has been further stabilized through numerous bug fixes, and many new add-on packages have been developed to provide a richer development experience." Click below for the full release announcement.

Full Story (comments: 5)

Desktop Applications

Accessibility

liblouis 1.5.2 has been released

Version 1.5.2 of liblouis has been announced, it is mainly a bug-fix release. "Liblouis is an open-source braille translator and back-translator. It features support for computer, literary and math braille, supports contracted and uncontracted translation for many, many languages. It plays an important role in an open source accessibility stack and is used by screenreaders such as NVDA and Orca. A companion project liblouisxml deals with formatting of braille."

Full Story (comments: none)

Audio Applications

Audacity 1.3.7 released

Version 1.3.7 of the Audacity audio editor has been announced. "This is primarily a bug-fix release which significantly improves stability and usability, especially on Mac OS X. It incorporates some new features too, including DirectSound device support for Windows.".

Comments (none posted)

jack_capture 0.9.32 released

Version 0.9.32 of jack_capture has been announced, it includes some new features and bug fixes. "jack_capture is a program for recording soundfiles with jack. Its default operation is to capture whatever sound is going out to your speakers into a file, but it can do a number of other operations as well."

Full Story (comments: none)

CAD

Kicad 2008-08-25 released (Open Collector)

OpenCollector.org has announced the release of Kicad version 2008-08-25. "Kicad is an open source (GPL) software for the creation of electronic schematic diagrams and printed circuit board artwork. Kicad is an integrated set of four programs and a project manager".

Comments (2 posted)

Desktop Environments

The "Compiz Council" created

In response to ongoing concerns about the future of the Compiz compositing window manager, a group of developers has formed into the "Compiz Council," which will attempt to drive the project forward. Announced plans include merging the Compiz Fusion project, moving away from freedesktop.org, and putting out a stable release sometime in August or September.

Full Story (comments: none)

GNOME Software Announcements

The following new GNOME software has been announced this week: You can find more new GNOME software releases at gnomefiles.org.

Comments (none posted)

KDE Commit-Digest (KDEDot)

The January 18, 2009 edition of the KDE Commit-Digest has been announced. The content summary says: "A new "Crystal Desktop Search" Plasmoid, allowing searching through NEPOMUK indexes (and MediaWiki-based websites). Support for "grep-like behaviour" in the "FileWatcher" Plasma applet, and support for custom server addresses (aka. backend locations) for the "Pastebin" applet. Further developments in the "System Load Viewer" (which moves to kdereview for KDE 4.3) and "Video Player" applets..."

Comments (none posted)

KDE Software Announcements

The following new KDE software has been announced this week: You can find more new KDE software releases at kde-apps.org.

Comments (none posted)

Xorg Software Announcements

The following new Xorg software has been announced this week: More information can be found on the X.Org Foundation wiki.

Comments (none posted)

GUI Packages

AVC 0.7.0 released

Version 0.7.0 of AVC has been announced, some new features have been added. "AVC is a multiplatform, fully automatic, live connection among graphical interface widgets and application variables for the python language. AVC supports in a uniform way the most popular widget toolkits: GTK+, Qt3, Qt4, Tk, wxWidgets."

Full Story (comments: none)

Interoperability

Wine 1.1.14 announced

Version 1.1.14 of Wine has been announced. Changes include: "Various bug fixes for Internet Explorer 7. Many crypt32 improvements, including new export wizard. Better support for windowless Richedit. Improvements to the print dialog. Many fixes to the regression tests on Windows. Various bug fixes."

Comments (none posted)

Music Applications

zynjacku 4 is out

Version 4 of zynjacku has been announced. "In this release: * lv2rack does no longer require PHAT (it was not really using it even in zynjacku-3 release) * Support for out of process plugin UIs (the upcomming nekobee release should use it) * Don't crash when trying to load non-existing plugin (specified by supplying plugin URI at commandline) * Don't crash with some plugins (NULL extension_data). zynjacku is JACK based, GTK (2.x) host for LV2 synths."

Full Story (comments: none)

Office Suites

OpenOffice.org Newsletter

The January, 2009 edition of the OpenOffice.org Newsletter is out with the latest OO.o office suite articles and events.

Full Story (comments: none)

Web Browsers

Firefox 3.0.6 released

The Firefox 3.0.6 update is out. This version fixes yet another pile of security issues and a number of other bugs as well; see the release notes for details.

Comments (33 posted)

Miscellaneous

SimPy 2.0 released

Version 2.0 (major new version) of SimPy has been announced. "SimPy is a process-based discrete-event simulation language based on standard Python and released under the GNU LGPL. It provides the modeller with components of a simulation model. These include processes, for active components like customers, messages, and vehicles, and resources, for passive components that form limited capacity congestion points like servers, checkout counters, and tunnels. It also provides monitor variables to aid in gathering statistics."

Full Story (comments: none)

Languages and Tools

C

GCC 4.3.3 released

Version 4.3.3 of GCC, the GNU Compiler Collection, has been released. "GCC 4.3.3 is a bug-fix release containing fixes for regressions and serious bugs in GCC 4.3.2."

Full Story (comments: none)

GCC 4.4.0 Status Report

The January 31, 2009 edition of the GCC 4.4.0 Status Report has been published. "The trunk remains Stage 4, so only fixes for regressions (and changes to documentation) are allowed. The number of P1, P2 and P3 regressions is already under 100 and the only remaining P1 has a patch approved. The old register allocator has been removed. The 4.4 branch will be created when all the P1 fixes are committed and the licensing changes (see the GCC Runtime Library Exception thread on gcc mailing list) land on the trunk."

Full Story (comments: none)

Caml

Caml Weekly News

The February 3, 2009 edition of the Caml Weekly News is out with new articles about the Caml language.

Full Story (comments: none)

Java

[fleXive]: 3.0.2 released (SourceForge)

Version 3.0.2 of [fleXive] has been announced. "[fleXive] is a Java EE 5 framework that provides an enterprise-level persistence engine with security and versioning, a SQL-like query language, a JSF-based web administration and reusable JSF components for integration into existing applications. [fleXive] 3.0.2, the second bugfix release for [fleXive] 3.0, has been released. It contains important bugfixes for our last release, and keeps binary compatibility with 3.0.0."

Comments (none posted)

IcedTea6 1.4 released

Version 1.4 of IcedTea6 has been announced, it includes security and bug fixes. "The IcedTea6 project provides a harness to build the source code from OpenJDK6 using Free Software build tools."

Full Story (comments: none)

MathJ: 0.7 Released (SourceForge)

Version 0.7 of Mathj has been announced. "Java library for simple managing and solving sophisticated mathematic expressions and equations, based on Reverse Polish Notation (RPN) First version of MathJ is available for download."

Comments (none posted)

Inside Zero and Shark

Mark Wielaard has sent in this update on Gary Benson's latest work: "Gary Benson is writing a series of blog posts called about Zero and Shark. Zero is an interpreter-only port of OpenJDK that uses no assembler based on libffi. Shark is a just-in-time (JIT) compiler for Zero based on LLVM. They provide an universal architecture port of Java and are currently included in the IcedTea project. Inside Zero and Shark has published three installments this far: Java threads and state transitions, Handles and Oops, Traps and Checks and Calling Conventions and The Call Stub."

Comments (none posted)

Perl

This Week on perl5-porters (use Perl)

The January 18-25, 2009 edition of This Week on perl5-porters is out with the latest Perl 5 news.

Comments (none posted)

Python

gmpy 1.04 released

Version 1.04 of gmpy has been announced, some new capabilities have been added. "gmpy is a wrapper for the GMP multiple-precision arithmetic library. This version of gmpy also supports the MPIR multiple-precision arithmetic library."

Full Story (comments: none)

Announcing Pyflakes 0.3.0

Version 0.3.0 of Pyflakes has been announced. "This release fixes several bugs, improves compatibility with recent versions of Python, and new flake checks. Pyflakes is a static analysis tool for Python source. It is focused on identifying common errors quickly without executing Python code. It is a handy supplement to your project's test suite."

Full Story (comments: none)

PyMite release 06 announced

Release 06 of PyMite has been announced. "PyMite is a flyweight Python interpreter written from scratch to execute on 8-bit and larger microcontrollers with resources as limited as 64 KB of program memory (flash) and 4 KB of RAM. PyMite supports a subset of the Python 2.5 syntax and can execute a subset of the Python 2.5 bytecodes. PyMite can also be compiled, tested and executed on a desktop computer."

Full Story (comments: none)

Python-URL! - weekly Python news and links

The January 27, 2009 edition of the Python-URL! is online with a new collection of Python article links.

Full Story (comments: none)

Python 3 primer, Part 1: What's new (IBM developerWorks)

IBM developerWorks introduces Python 3 in the first of a multi-part series. "Python 3 is the latest version of Guido van Rossum's powerful general-purpose programming language. It breaks backwards compatibility with the 2.x line but has cleaned up some syntax issues. This article is the first in a series that talks about the changes that affect the language and backwards compatibility, and it provides examples of new features."

Comments (1 posted)

Tcl/Tk

Tcl-URL! - weekly Tcl news and links

The February 3, 2009 edition of the Tcl-URL! is online with new Tcl/Tk articles and resources.

Full Story (comments: none)

Editors

python-mode.el 5.1.0 announced

Version 5.1.0 of python-mode.el has been announced. "I've just released version 5.1.0 of python-mode.el, a Python editing mode for Emacs and XEmacs. Since 5.0.0, this contains a fix to the syntax highlighting for None and places the file under the GPLv3."

Full Story (comments: none)

Libraries

RFIDIOt 0.1w released

Version 0.1w of RFIDIOt, the open source python RFID library, has been announced. "I've been working on adding Global Platform functionality to non-PC/SC devices so folks with LAHF and HF ACG devices can play with JCOP cards... It's not quite there yet, but jcoptool.py is a work in progress which currently supports printing manufacturer info and card contents. I'll be working on installing/deleting applets next. Other fixes are mostly to do with e-passports..."

Full Story (comments: none)

Version Control

EasyGit (eg) 0.97 released

Version 0.97 of EasyGit (eg) is available. "Easy Git (eg) is an alternative frontend for git, specifically designed for former cvs and svn users in order to provide a lower learning curve and prevent common user errors. Since eg largely looks and feels like core git, eg can also serve as a training tool to teach users git (see below for similarities and how to display git commands that eg uses). There is a detailed side-by-side comparison of svn and eg to help svn users make the switch. eg is trivial to install and try out: simply download a single file and stick it in your PATH."

Full Story (comments: none)

GIT 1.6.1.2 released

Version 1.6.1.2 of the GIT distributed version control system has been announced. "People with 1.6.1 or 1.6.1.1, who push into a repository that borrows objects from other repositories via "alternates" mechanism (most of the linux kernel subsystems hosted on k.org, and "forks" on various public hosting site such as repo.or.cz and github fall into this category), may want to upgrade to this version, as these two versions have a buggy "git push" that does not like such a repository served by git 1.6.1 or newer."

Full Story (comments: none)

Page editor: Forrest Cook
Next page: Linux in the news>>


Copyright © 2009, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds