Bisecting with live ebuilds

From Gentoo Wiki
Jump to:navigation Jump to:search

Introduction

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.

Steps

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

user $git clone https://github.com/openzfs/zfs -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/test-zfs.sh
export EGIT_OVERRIDE_COMMIT_OPENZFS_ZFS=$(git rev-parse HEAD)
export EGIT_OVERRIDE_BRANCH_OPENZFS_ZFS=zfs-2.1.5-staging
export ACCEPT_KEYWORDS="**"
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/test-zfs.sh 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.

See https://lwn.net/Articles/317154/.

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/test-glibc.sh
#!/bin/bash
export EGIT_OVERRIDE_COMMIT_GLIBC=$(git rev-parse HEAD)
export EGIT_OVERRIDE_BRANCH_GLIBC=release/2.35/master
export ACCEPT_KEYWORDS="**"
#USE="vanilla" ...
emerge -v1 sys-libs/glibc || exit 1