Skip to content

LCOV parser breaks on DA lines with optional checksum field #1501

Description

@robertomlsoares

The LCOV format allows an optional checksum field on DA lines: DA:line_number,execution_count[,checksum]

grcov's byte-level LCOV parser does not consume the optional checksum field after reading the execution count. Depending on what character the checksum starts with, this causes different issues.

  1. checksum starts with e (interpreted as end_of_record):
SF:test.py
DA:1,0,e3ZBlmsTAEA3QwKvJLg9CA
LH:0
LF:1
end_of_record
A panic occurred at src/parser.rs:194: called `Option::unwrap()` on a `None` value
  1. checksum starts with a valid key prefix like FN, DA, FNDA:
SF:test.py
DA:1,0,FNsomechecksum
LH:0
LF:1
end_of_record
Error parsing file: Invalid record: 'FN at line 3'
  1. checksum starts with SF or BRDA:
SF:test.py
DA:1,0,SFsomechecksum
LH:0
LF:1
end_of_record
No error, but the checksum is interpreted as a new source file record, silently corrupting the output.

I have tried tackling the issue here #1500 before realising it is more widespread, and not isolated to just checksums starting with e.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions