On macOS, lcovutil.pm loads itself twice and warns "Subroutine ... redefined" for each subroutine

Open Beginner friendly
#574 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
perl
Domain
tooling

Research direction

Start in lib/lcovutil.pm at the require LcovUtil call (line 20359 on master, 14192 in 2.6) and look at the check for lib/LcovUtil/blib that already guards the @INC entry. Reproduce with the two genhtml --version commands in the issue: the default run prints 442 redefined warnings, the LCOV_PURE_PERL=1 run prints none. Done means a run on a case-insensitive filesystem emits no warnings while still loading the extension when blib is present, so test both branches.

Written by the indexing model from the issue text.

Description

On macOS, whose default APFS filesystem is case-insensitive, every genhtml or lcov run from the 2.6 release prints a warning for each subroutine of lcovutil.pm, 442 of them:

Subroutine posix_path redefined at .../lcov-2.6/bin/../lib/LcovUtil.pm line 139.
Subroutine posix_paths redefined at .../lcov-2.6/bin/../lib/LcovUtil.pm line 164.
...

To reproduce on macOS (seen on macOS 27.2.1 with its /usr/bin/perl 5.34.1):

curl -LO https://github.com/linux-test-project/lcov/releases/download/v2.6/lcov-2.6.tar.gz
tar xzf lcov-2.6.tar.gz
lcov-2.6/bin/genhtml --version 2>&1 | grep -c redefined                   # 442
LCOV_PURE_PERL=1 lcov-2.6/bin/genhtml --version 2>&1 | grep -c redefined  # 0

lib/lcovutil.pm tries the optional C++ extension with require LcovUtil (line 14192 in 2.6, line 20359 on master), which the release does not build. On a case-sensitive filesystem, that require fails and LCOV falls back to pure Perl, as intended. On a case-insensitive one, lib/LcovUtil.pm finds lib/lcovutil.pm, so Perl loads it a second time as LcovUtil.pm. That redefines every subroutine and runs its initialization again; $LcovUtil::XS_LOADED then stays undefined, so LCOV still falls back to pure Perl. The reports come out right, but behind hundreds of warnings.

LCOV_PURE_PERL=1 avoids it. A fix could require LcovUtil only when lib/LcovUtil/blib exists, which is already checked before adding it to @INC.

Dominant language
Shell
Stars
1.1k
Forks
272
Avg merge
2h 42m
Merged PRs (30d)
8

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from linux-test-project/lcov

All issues in linux-test-project/lcov

Similar issues

More Shell/Bash issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.