QA/Bibisect/ja

はじめに
bibisectとは「binary bisect」（実行形式によるbisect）の意味で、LibreOfficeのQAでリグレッション（訳注：機能追加やバグ修正の副作用によって起こるバグ）を扱う助けとなるためのものです. リグレッションは最も厄介な事象の一つで、ソフトウェア開発およびQAに伴って不幸にして起こるものです. しかし、リグレッションはできるかぎり素早く、早期に発見したいものでもあり、時間が経てば経つほど、トリアージや修正が困難になるものなのです.

Bibisect作業はどのようにするのか?
Each bibisect package is a git repository populated with hundreds or thousands of builds of LibreOffice. Added to the repository in chronological order, the builds provide a fast and simple way for us to test a bug against many different versions without having to compile LibreOffice each time we switch.

We can leverage the tools built into git for binary search through commits (e.g. git bisect) as well as benefit from the compression and de-duplication included in git. For example, in a series of builds that each might take up 500MB of disk space, through de-duplication we can potentially use only 25MB per build.

Watch Effective Bisection and Bibisection (Matthew Francis's talk at LibOCon 2015 on YouTube) for both an introduction, and practical details.

概要
A successful bibisect will leave developers with only a few commits to search through to find the 'culprit' commit that we believe introduced a regression. Depending upon the particular bibisect repository, this range might be 60, 100, or even 2 commits. (We also have some very 'coarse' bibisect repositories that use released versions + beta + RC builds, and these may have ranges spanning multiple hundreds of commits) QA can go the additional step of fully bisecting (determining the exact commit) or can leave this to the developers. Often times, it's easy to find the commit that caused the issue after bibisecting the bug.

With approximately 10 gigs, you'll have hundreds of builds to work with. A bibisect can take as little as 15 minutes.

Currently bibisecting is possible on:
 * GNU/Linux (64 bit)
 * macOS
 * Windows

As can be seen from the Commits in range and Number of builds, depending upon the particular bibisect repository, this range might be on average 80 commits for old "43max" repository (reaching hundreds of source commits in some builds) to just 1 or 2 commits for newer repositories. (We also have some very 'coarse' bibisect repositories that use released versions + beta + RC builds, and these may have ranges spanning multiple hundreds of commits).

If build commit or range is found, bug is marked with keyword "bibisected", and if source commit is found, bug is additionally marked "bisected".

概略説明
It might be a good idea for beginners to start by tracing the steps of a bibisect that was already completed successfully. For this purpose we have a bibisecting tutorial.

Note: Each operating system is different, please read the full instructions that correspond to your specific operating system (GNU/Linux, macOS, or Windows) for more complete instructions, instructional videos, and other related information.

Bibisecting relies on 6 steps:


 * 1) Setting up your environment, including installing any extra software
 * 2) Downloading the bibisect package
 * 3) Bibisecting the bug
 * 4) Getting a bibisect log
 * 5) Attaching the bibisect log to the bug report
 * 6) Updating the bug report fields
 * 1) Attaching the bibisect log to the bug report
 * 2) Remove keyword 'bibisectRequest' from Keywords field and add the keyword 'bibisected'
 * 3) If the commit causing the regression has been identified, also add the keyword 'bisected', add the developer as CC and add the comment 'Adding Cc: to '

Note that you should only add the original committer to the CC, not any reviewers. If a developer has retired from the project (check the date of their last commits), there is no point in adding anyone to the CC. Rather in this case, you should bump the priority of the bug report.

Some bibisect repositories have ranges of source commits folded into a single chunk. If after completing a bibisect you are presented with only a single one of these chunk commits, you can get the range by first copying the hash (note: not the source hash) and using it in a git log command like so: Now you can copy the source hashes of the first and previous displayed commits and use them to construct a range query like so: https://git.libreoffice.org/core/log/7c4d3ea6ba4d42b4dda5148a00c8c411b5d7703d..5b195fbcf7a441aeb193f6abd08b877e580938e0 This will allow you to skim commit messages looking for related subjects. For deeper scrutiny, see the section on detective work.

制限事項
Performing a bibisect is only possible if we have a repository available for the correct OS, covering the correct range of LibreOffice commits. We have very good coverage on GNU/Linux, and are improving our coverage on Windows and macOS.

Some regressions are difficult to reproduce, and may require multiple test runs for a bug to appear. As you may imagine, trying to bibisect such regressions is very difficult, and requires one to perform many test runs after each checkout of a new version of LibreOffice to give some security / statistics that the bug is indeed present or not present with the given version.

We do not currently have bibisect support for
 * LibreOffice for Android
 * BSDs (although the GNU/Linux bibisect packages may run, with minor tweaks)
 * LibreOffice Online
 * LibreOffice Vanilla for Mac (in the Mac App Store)

バージョン
Versions are listed on each OS page. See above.

Bibisectできない
Some bugs are not bibisectable. These include
 * Bugs that don't show up on a supported platform (see )
 * Bugs that predate our bibisect builds (We're working on extending the range covered)
 * Bugs that depend upon build options not enabled in the TDF builds (e.g. -kde)

If a bug with bibisectRequest Keyword is found to be not bibisectable, leave a comment on the bug explaining why we're not able to use bibisect to track down the introduction of this problem, and replace Keyword bibisectRequest with notBibisectable. If a bug predates bibisect builds, replace Keyword bibisectRequest with preBibisect.

Finding bugs needing bibisect
The following bugs with keyword bibisectRequest are waiting for a bibisect:

In addition all unresolved regressions in LibreOffice might benefit from bibisecting.

既にbibisectされたバクの発見
With the above info added to the bug a developer knows that the regression was introduced between the commits fb754a0df859e30255c25af8fa19bfaa75f257e7 (good) and 2d19e9bb07ccff3134f855812dddfda5c07b1fe4 (bad) on master. The above command ran in the source repository will show the 128 commits including the one that introduced the bug, making it a lot easier for the developer to close in on the culprit. For more details, see:
 * bisect in the git community book
 * discussion on the developer list

Bibisecting language-specific bugs
The TDF bibisect repositories provided do not include any lang-packs.

To bibisect bugs which work good with english UI, but bad with non-english UI (like CJKs): one should copy-paste the following files, from a release build which has your language, to the same location of the bibisect repo:


 * 1) program/resource/
 * 2) share/registry/Langpack-.xcd
 * 3) share/registry/res/fcfg_langpack_.xcd
 * 4) share/registry/res/registry_.xcd

The suggested language resources you should copy is the one for the same major branch. For example, for the bibisect-linux-64-6.0 repo, you can copy from 6.0.1.1 release.

ユーザープロファイルを分けて実行する
To create separate profile directory in /tmp/ (which will be automatically removed during the next machine boot): If you want to start fresh for each bisect iteration, you can add git commit hash to directory name. For example:

修復を見つける
Sometimes a bug is a collateral damage of another (possibly minor) bug, in a non obvious way. In such cases that other bug might be fixed on master, but was not backported to the release branch. To identify a problem-fixing commit you can use: As you test, say  or   as appropriate.

If the fix is small and important enough, it likely can be easily backported to the release branch.

Checking out a specific commit based on source hash
Sometimes you already know a specific source commit has/does not have the bug you are hunting.

Copy the source hash from the LibreOffice git history and use it to grep in the bibisect repo log like so:

git log --all --grep='29a9f433c268414747d8ec7343fc2b5987971738'

Copy the commit hash of the bibisect repo and do a checkout for it to verify your assumption:

git checkout 38758b70f5278d4d8292a2e857e80a9a1130f38e

You can use the repo commit hash when determining the bad-good range to bisect:

git bisect start 38758b70f5278d4d8292a2e857e80a9a1130f38e oldest

Doing detective work inside a commit range
In case your bibisect result is a range of commits and you have trouble locating the offending commit, you might make your life easier by searching with a keyword.

An example for a case, where we know the problem is in Calc's Navigator view: Adjust the -B and -A grep parameters to control how many lines before and after the hit you want to display. When piping to less, -R preserves the colouring of search results.

Bisect skip hell
Sometimes we get stuck in a miserable situation, where we have to use git bisect skip over and over again due to various reasons. There are ways of getting out of these infuriating messes and here we will show one of them.

Example bug:

Bug appeared in 4.0-4.1 range.

There are lots of commits, where the autofilter is not shown at all, so have to skip those.

We can use git bisect visualize to show us the remaining suspected commits: The earliest bad results are at the top while the ones you have skipped are at the bottom. The commit below the bottom is the last known good one.

My top results included b842ac1 source-hash-7b4d76772ef76a8de852ed647ed0cad368f70189 40ef04e source-hash-dc173b7f2a550185404aacbc6da744cb6d1880fc 8e697de source-hash-eb96e4325278f31b9e6fbc1d5c6a01543204ded6

So I did git checkout b842ac1, test, continue with the next etc. Turns out the third one from the top was already a skippable commit.

I made a range query with the source hashes in the style bottomcommit..firstbadcommit.

In the displayed results I searched for "filter" and found a suspicious commit about sorting autofilter popup items.

If soffice is failing with a non-zero exit code--this probably means a crash--a solution under QA/Bibisect/Automation offers a script to ease the pain of repeatedly skipping failed probes.

Finding source commits from bibisect
If bibisect was done, but not likely to be correct or in a repository known to have large range of source commits, we can check the range by finding a previous build commit from the found one and then find the source range.

トラブルシューティング
Please add your problems and how you solved them. This section covers issues that affect more than one OS. For OS-specific issues, please see the individual OS wiki pages.

除外できないファイル
If you can't extract files (you should get an error message). Try to rename the file from *.tar.lzma to *.tar.xz.

思いがけなく修正されたLbreOfficeがインストールされた
Problem / Messages:

Problem / Messages: error: Your local changes to the following files would be overwritten by checkout: opt/program/pythonloader.pyc opt/program/uno.pyc opt/program/unohelper.pyc Please, commit your changes or stash them before you can switch branches. Aborting

Solutions:

The above command will repair the problem. Afterwards you can start the next test run as usual with

If that does not solve the problem, you can try the following commands:

The ultimate repair is to delete everything except one hidden .git/ folder, and do

sofficeがスタートできない
Problem 1: Upon trying to run soffice within bibisect you receive the error "unexpected operator terminate called after throwing an instance of 'com::sun::star::uno::DeploymentException'

Problem 1: Upon trying to run soffice within bibisect you receive the error "unexpected operator terminate called after throwing an instance of 'com::sun::star::uno::DeploymentException'

Solution: Reset your libreoffice profile located in ~/.config/libreoffice. Make sure to backup the folder if you have any settings you'd like to preserve for use with your stable libreoffice release. After you're done with bibisect you can try to return your backed up profile to it's original location (ie. delete the new profile folder and replace it with the backed up one)

Problem 2: Trying to run soffice within bibisect gives frequent errors such as "Application Error" and skipping via 'git bisect skip' is tedious.

Solution: Upon an error, run one-line script to skip commit on error message and try the next one. Script will stop when soffice is successfully run and then you proceed with 'git bisect good' or 'git bisect bad'. If error is repeated, script can be run again.

How to bisect RTL bugs
In case you need to bisect a RTL ( Right-To-Left ) bug, please import this variable before calling LibreOffice:

How to bisect File Recovery bugs
In case you need to bisect File Recovery bugs ( e.g. ), comment out line OOO_DISABLE_RECOVERY=1 in file instdir/program/ooenv

You may also use user control:

How to bisect file hanging / CPU or memory exhaustion bugs
In case you need to bisect file hanging/memory exhaustion bugs, you may limit memory or CPU or time execution.

In Linux, timeout utility can be used. To avoid confusion with built-in "timeout" command, here it's renamed to "tmt".

For example, if LibreOffice 'good' commit opens a file with 1 GB of memory, you may set soffice memory limit to 1.500.000 kilobytes to avoid 'bad' commit hanging your computer.

Or, to limit CPU+SYS time (where normal time is seen with successful run):

More advanced option is to use benchexec utility. User needs to be added to the appropriate group (benchexec). Runexec can be used to execute a single command while measuring its resource consumption, similarly to the tool "time" but with more reliable time measurements and with measurement of memory usage.

In Windows, process-governor utility can be used.

Automation
See the separate article on automating bisecting.

ノート
For details on how the bibisect archives are generated:
 * QA/Bibisect/Implementation