gcov out of memory / mismatched version?
Asked Answered
S

4

24

Just trying to get gcov up and running, getting the following error:

$ gcov src/main.c -o build
build/main.gcno:version '404*', prefer '407*'

gcov: out of memory allocating 14819216480 bytes after a total of 135168 bytes

I'm using clang/profile_rt to generate the files gcov needs, I'm assuming that might have something to do with it. It's working on my other computer, though, so I assume it can be fixed somehow.

Subtrahend answered 17/9, 2012 at 6:35 Comment(0)
S
25

I just had the same problem on my machine.

Make sure your versions of gcov and the compiler you use match.

I had this exact problem when compiling with g++-4.7 and I had gcov 4.6.

On my machine sudo apt-get install ggcov got me the latest version. I then had to sudo ln -sf /usr/bin/gcov-4.7 /usr/bin/gcov to make gcov point in the right place.

Strode answered 3/2, 2013 at 19:20 Comment(3)
Thanks for the help! I got around the problem by simply executing gcov-4.7 instead of gcov. I suppose a more elegant approach would involve using update-alternatives, if I were motivated.Canorous
Thanks Anthony! And ln -sf can automatically remove the old gcov for you.Laurustinus
Thanks @EricZ. Updated :DStrode
A
13

My problem was that I updated gcc and g++ so that I could use a newer compiler, but forgot to update the gcov version meaning running "gcov" or "lcov" picked up the previous compilers version of gcov.

So basically running g++ --version and gcov --version should yield the same version number else things are going to go very wrong.

Here is how I updated my compiler version, the last line being what I was missing to get it all working.

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 90
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 90
sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-4.9 90
Annia answered 12/1, 2015 at 13:46 Comment(0)
H
10

I just had the same problem and I had the correct versions installed. Solution in my case: remove all *.gcda files from any subdir you compile in. My make clean did not cover them.

Haldane answered 14/5, 2014 at 12:7 Comment(1)
Thanks. Had me head scratching for a while!Govern
T
0
  1. Running gcov with -v flag you can get the exact execution gcov command. It may help to understand what happens.
  2. In my case, specifying gcov version helped to solve the issue: gcovr --gcov-executable gcov-7
Trevethick answered 30/11, 2023 at 16:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.