linux-test-project / lcov

LCOV
GNU General Public License v2.0
866 stars 234 forks source link

genhtml: ERROR: Can't call method "branchElem" on an undefined value #293

Closed icsfy closed 1 month ago

icsfy commented 1 month ago

Lcov 2.1, use genhtml --branch --keep-going to generate differential coverage, failed with these output:

genhtml: ERROR: (unmapped) no data for line:279, TLA:ECB, file:somefile.c
    (use "genhtml --ignore-errors unmapped ..." to bypass this error)
genhtml: ERROR: (unmapped) no data for line:281, TLA:EUB, file:somefile.c
genhtml: ERROR: (unmapped) no data for line:283, TLA:ECB, file:somefile.c
genhtml: ERROR: Can't call method "branchElem" on an undefined value

If --parallel is enabled, genhtml seems hangs at above error and not terminated. I checked that somefile.c, it only contains 276 lines. gcc version 9.4.0

henry2cox commented 1 month ago

Thanks for the report. I believe this is already fixed in my TOT - so I will push the update shortly.

Note that the root cause is related to data inconsistency: the baseline, current, and source diff data do not agree with each other. In our case, the issue was that the file paths in the 'diff' file did not match the names in the coverage data; the tool requires that path names be identical (however, see the genhtml --elide-path-mismatch .. documentation for a workaround). The bug fix simply removes the call to the undef object (so no crash) - but you will still see the unmapped error. The fix also adds some additional text to the output logs, to make it easier to diagnose the cause of the mismatch.

The out-of-range line number issue is commonly caused by one or more of:

henry2cox commented 1 month ago

call from undef object should be fixed in 3abff7c68.