llvm/llvm-project

llvm-objcopy crashes with unreachable error when (de)compression requested without selected value available

クローズ

#197,877 opened on 2026/05/15

 (8 件のコメント) (0 件のリアクション) (0 人の担当者)C++ (10,782 件のフォーク)batch import
good first issuetools:llvm-objcopy/strip

Repository metrics

Stars
 (26,378 個のスター)
PR merge metrics
 (平均マージ 1d 2h) (30d で 1,000 merged PRs)

説明

llvm-objcopy crashes due to calling llvm_unreachable when compression::compress or compression::decompress is called without the selected compression type being installed on the machine.

The problem is that the tool doesn't call compression::getReasonIfUnsupported before compression::compress or compression::decompress. The correct thing to do is to call that first, then check the result and either report an Error based on the result or continuing and (de)compress as requested.

Discovered while triaging #197813.

I'll label this with good first issue as it's a trivial fix (but I don't have the personal time to fix it and put a PR up myself). There should be two tests for it. The first test should test that the correct error is emitted for zlib compression and decompression and the second the same for zstd. Each test should only run if zlib/zstd is NOT enabled on the target (i.e. something like UNSUPPORTED: zlib, but check other examples for REQUIRES/UNSUPPORTED tags to see the exact way of writing that).

コントリビューターガイド