Error parsing gcov branch information with negative count

Open
#908 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
testing, tooling

Research direction

Start at src/parser.rs:411 and compare the failing branch-count parsing with the approach discussed in #803. Reproduce the error using the shown gcov JSON containing a count of -1, then verify that grcov no longer panics and handles the input with an appropriate result or diagnostic.

Written by the indexing model from the issue text.

Description

I think this is similar to #570. When running grcov on a fairly large codebase I see the following error:

$ grcov --branch ./main
17:46:15 [ERROR] A panic occurred at src/parser.rs:411: called `Result::unwrap()` on an `Err` value: Error("Unable to parse u64 from -1", line: 1, column: 12387510)

Running gcov manually and inspecting the *gcov.json.gz files the offending entry is:

{
  "branches": [
    {
      "fallthrough": true,
      "count": 783,
      "throw": false
    },
    {
      "fallthrough": false,
      "count": -1,
      "throw": false
    }
  ],
  "count": 782,
  "line_number": 83,
  "unexecuted_block": false,
  "function_name": "_ZN15_CORBA_SequenceIN5Tango8DevErrorEE8allocbufEj"
}

I am using gcov/gcc version 11.3.0 and grcov 0.8.12 (also 0.8.11). Probably this is also a bug in gcov but would a fix like #803 be desired here?

On another note, running grcov with --log-level DEBUG or similar options didn't seem to produce any useful output in this case. I had to do some manual searching to find what file was actually causing the issue.

Dominant language
Rust
Stars
1.4k
Forks
170
Avg merge
3d 10h
Merged PRs (30d)
4

Contributor guide

No contributing guide indexed for this repository

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 mozilla/grcov

All issues in mozilla/grcov

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.