Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCov output parsing error makes gcovr crash #331

Closed
leandrosansilva opened this issue Sep 9, 2019 · 2 comments
Closed

GCov output parsing error makes gcovr crash #331

leandrosansilva opened this issue Sep 9, 2019 · 2 comments

Comments

@leandrosansilva
Copy link

I am using gcovr on msys2 (windows 10) and an external mingw64 environment to get reports (the same environment works fine with lcov), and get some fatal errors.

gcovr --version, installed with pip install gcovr:

gcovr 4.1

Copyright 2013-2018 the gcovr authors
Copyright 2013 Sandia Corporation
Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
the U.S. Government retains certain rights in this software.

The executed command:

gcovr --gcov-executable /c/dev/libs/compiler_mingw//bin/gcov -r .
(WARNING) Unrecognized GCOV output for /c/dev/workspaces/pkgctrl_workspace/pkgctrl/target/coverage/windows/main/portable/proto/common
_types.pb.cc


        This is indicative of a gcov output parse error.
        Please report this to the gcovr developers
        at <https://github.com/gcovr/gcovr/issues>.
(WARNING) Exception during parsing:
        IndexError: string index out of range
(ERROR) Exiting because of parse errors.
        You can run gcovr with --gcov-ignore-parse-errors
        to continue anyway.
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/gcovr/workers.py", line 71, in worker
    work(*args, **kwargs)
  File "/usr/lib/python3.7/site-packages/gcovr/gcov.py", line 564, in process_datafile
    options=options, logger=logger, toerase=toerase, errors=errors, chdir=dir_, tempdir=workdir)
  File "/usr/lib/python3.7/site-packages/gcovr/gcov.py", line 675, in run_gcov_and_process_files
    process_gcov_data(fname, covdata, abs_filename, options)
  File "/usr/lib/python3.7/site-packages/gcovr/gcov.py", line 117, in process_gcov_data
    ignore_parse_errors=options.gcov_ignore_parse_errors)
  File "/usr/lib/python3.7/site-packages/gcovr/gcov.py", line 233, in parse_all_lines
    self.check_unrecognized_lines(ignore_parse_errors=ignore_parse_errors)
  File "/usr/lib/python3.7/site-packages/gcovr/gcov.py", line 464, in check_unrecognized_lines
    raise ex
  File "/usr/lib/python3.7/site-packages/gcovr/gcov.py", line 227, in parse_all_lines
    self.parse_line(line, exclude_unreachable_branches)
  File "/usr/lib/python3.7/site-packages/gcovr/gcov.py", line 270, in parse_line
    is_code_statement = self.parse_code_line(status, code)
  File "/usr/lib/python3.7/site-packages/gcovr/gcov.py", line 286, in parse_code_line
    firstchar = status[0]
IndexError: string index out of range
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/gcovr/workers.py", line 71, in worker
    work(*args, **kwargs)
  File "/usr/lib/python3.7/site-packages/gcovr/gcov.py", line 564, in process_datafile
    options=options, logger=logger, toerase=toerase, errors=errors, chdir=dir_, tempdir=workdir)
  File "/usr/lib/python3.7/site-packages/gcovr/gcov.py", line 675, in run_gcov_and_process_files
    process_gcov_data(fname, covdata, abs_filename, options)
  File "/usr/lib/python3.7/site-packages/gcovr/gcov.py", line 117, in process_gcov_data
    ignore_parse_errors=options.gcov_ignore_parse_errors)
  File "/usr/lib/python3.7/site-packages/gcovr/gcov.py", line 233, in parse_all_lines
    self.check_unrecognized_lines(ignore_parse_errors=ignore_parse_errors)
  File "/usr/lib/python3.7/site-packages/gcovr/gcov.py", line 464, in check_unrecognized_lines
    raise ex
  File "/usr/lib/python3.7/site-packages/gcovr/gcov.py", line 227, in parse_all_lines
    self.parse_line(line, exclude_unreachable_branches)
  File "/usr/lib/python3.7/site-packages/gcovr/gcov.py", line 270, in parse_line
    is_code_statement = self.parse_code_line(status, code)
  File "/usr/lib/python3.7/site-packages/gcovr/gcov.py", line 286, in parse_code_line
    firstchar = status[0]
IndexError: string index out of range
Traceback (most recent call last):
  File "/usr/bin/gcovr", line 10, in <module>
    sys.exit(main())
  File "/usr/lib/python3.7/site-packages/gcovr/__main__.py", line 562, in main
    contexts = pool.wait()
  File "/usr/lib/python3.7/site-packages/gcovr/workers.py", line 160, in __exit__
    self.wait()
  File "/usr/lib/python3.7/site-packages/gcovr/workers.py", line 151, in wait
    raise self.exceptions[0][1]
  File "/usr/lib/python3.7/site-packages/gcovr/__main__.py", line 562, in main
    contexts = pool.wait()
  File "/usr/lib/python3.7/site-packages/gcovr/workers.py", line 151, in wait
    raise self.exceptions[0][1]
  File "/usr/lib/python3.7/site-packages/gcovr/workers.py", line 71, in worker
    work(*args, **kwargs)
  File "/usr/lib/python3.7/site-packages/gcovr/gcov.py", line 564, in process_datafile
    options=options, logger=logger, toerase=toerase, errors=errors, chdir=dir_, tempdir=workdir)
  File "/usr/lib/python3.7/site-packages/gcovr/gcov.py", line 675, in run_gcov_and_process_files
    process_gcov_data(fname, covdata, abs_filename, options)
  File "/usr/lib/python3.7/site-packages/gcovr/gcov.py", line 117, in process_gcov_data
    ignore_parse_errors=options.gcov_ignore_parse_errors)
  File "/usr/lib/python3.7/site-packages/gcovr/gcov.py", line 233, in parse_all_lines
    self.check_unrecognized_lines(ignore_parse_errors=ignore_parse_errors)
  File "/usr/lib/python3.7/site-packages/gcovr/gcov.py", line 464, in check_unrecognized_lines
    raise ex
  File "/usr/lib/python3.7/site-packages/gcovr/gcov.py", line 227, in parse_all_lines
    self.parse_line(line, exclude_unreachable_branches)
  File "/usr/lib/python3.7/site-packages/gcovr/gcov.py", line 270, in parse_line
    is_code_statement = self.parse_code_line(status, code)
  File "/usr/lib/python3.7/site-packages/gcovr/gcov.py", line 286, in parse_code_line
    firstchar = status[0]
IndexError: string index out of range

My project uses SCons as build system, and the it builds it in the directory target/coverage/windows, relative to the project root.

My GCC version is:

g++.exe (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 5.1.0
@latk
Copy link
Member

latk commented Sep 9, 2019

Thank you for reporting this! The error message indicates that the file generated by gcov includes an empty line. But the gcov format shouldn't contain empty lines…

If the file is otherwise a valid gcov file, you can add the --gcov-ignore-parse-errors option to still get coverage reports. But this doesn't actually solve the problem.

Would it perhaps be possible to see the problematic gcov file, if necessary with the source code in it redacted? When gcovr crashes with the above error message, it should leave a file called _types.pb.cc.gcov somewhere in your target folder.

@Spacetown
Copy link
Member

Closing because related to the old parser. If problem persists with latest master, please reopen.

@Spacetown Spacetown modified the milestone: Upcoming release Aug 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants