Bisecting with live ebuilds

From Gentoo Wiki
Jump to:navigation Jump to:search


Suppose one hits a regression in ZFS. In this example, between ZFS 2.1.4 (last known good version) and ZFS 2.1.6 (being the latest version where a bug is hit).

git bisect is enormously helpful for debugging issues. Luckily, zfs*-9999 ebuilds can be used to do this easily.


First, clone ZFS at the zfs-2.1.5-staging branch:

user $git clone -b zfs-2.1.5-staging

Start the bisect:

user $git bisect start
user $git bisect bad zfs-2.1.5
user $git bisect good zfs-2.1.4

Create a simple script to allow easily building each commit:

FILE /tmp/
export EGIT_OVERRIDE_BRANCH_OPENZFS_ZFS=zfs-2.1.5-staging
emerge -v1 zfs zfs-kmod

echo "If this version is good (need to reboot), run 'git bisect good'."
echo "If this version is bad (need to reboot), run 'git bisect bad'."

Run /tmp/ repeatedly.

After each run of emerge by the script, test out ZFS by rebooting. If it worked, type git bisect good. If the bug remained, type git bisect bad. Continue until the first bad commit is identified.

Using git bisect run

git bisect has a 'run' subcommand which allows running a command or script to determine if a commit is good or bad.


For example, if sys-libs/glibc is failing in its last-minute sanity-check in pkg_preinst, it's sufficient to use the following script with the glibc git repository:

FILE /tmp/
export EGIT_OVERRIDE_COMMIT_GLIBC=$(git rev-parse HEAD)
export EGIT_OVERRIDE_BRANCH_GLIBC=release/2.35/master
#USE="vanilla" ...
emerge -v1 sys-libs/glibc || exit 1