Visitar URL original
`lcov` considers Coverage's function data inconsistent with its line data · Issue #2394 · coveragepy/coveragepy · GitHub
Skip to content

lcov considers Coverage's function data inconsistent with its line data #2394

Open

Description

@jakelishman

Describe the bug

Calling lcov --add-tracefile on a file generated by coverage lcov for executing a Python file with a function that is not called generates errors about "inconsistent" data in lcov complaining that the "line data" does not match the "function data".

To Reproduce

Locally I used lcov 2.6.0, but this reproduces on lcov 2.4-3 from the Ubuntu Resolute repos (26.04, as in GitHub's ubuntu-26.04) too.

File f.py:

def f():
    return True
coverage run -- f.py
coverage lcov
lcov -a coverage.lcov

This complains about:

Combining tracefiles.
... found 1 files to aggregate.
Reading tracefile coverage.lcov
lcov: ERROR: (corrupt) unable to read trace file 'coverage.lcov': lcov: ERROR: (inconsistent) "f.py":1: function 'f' is not hit but line 1 is.
   [... truncated ...]

The generated coverage.lcov file is

SF:f.py
DA:1,1
DA:2,0
LF:2,
FH:1
FN:1,2,f
FNDA:0,f
FNF:1
FNH:0
end_of_record

Answer the questions below:

  1. Python 3.13
  2. coverage==7.17.3
  3. no other Python packages
  4. repro above

Expected behavior

Combination should be successful.

Additional context

I'm not familiar with the coverage or lcov internals, but I suspect that changing the "function" information to register that the function starts on the line that contains the first non-signature line, as opposed to the line that includes the def statement would be suitable.

Explicitly: in my generated coverage.lcov file above, if I change the FN:1,2,f line to FN:2,2,f, lcov is happy to combine it. I think this is semantically valid: line coverage still shows that the def f(): line is hit without "contradicting" the function-hit data.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions