Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Devel-Cover CPAN distribution.

Report information
The Basics
Id: 70115
Status: resolved
Priority: 0/
Queue: Devel-Cover

People
Owner: Nobody in particular
Requestors: vpit [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.75
Fixed in: (no value)



Subject: "malformed JSON string" errors when gcov2perl is ran for XS distributions
When trying to run "cover -test" from any distribution that contains XS code, gcov2perl fails with a "malformed JSON string", and the reports aren't generated. The first version of Devel::Cover that shows this issue is 0.75. I've attached a simple XS distribution that replicates the problem. Thanks. Vincent Pit. ============================================================ $ cover5.14.1-64 --version /home/vince/perl/builds/bin/cover5.14.1-64 version 0.79 $ perl5.14.1-64 Makefile.PL ... $ make ... $ cover5.14.1-64 -test Deleting database /home/vince/perl/Wut/cover_db Use of uninitialized value $ENV{"DEVEL_COVER_TEST_OPTS"} in concatenation (.) or string at /home/vince/perl/builds/bin/cover5.14.1-64 line 209. cover: running make test "OPTIMIZE=-O0 -fprofile-arcs -ftest-coverage" "OTHERLDFLAGS=-fprofile-arcs -ftest-coverage" cc -c -fno-strict-aliasing -pipe -fstack-protector -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O0 -fprofile-arcs -ftest-coverage -DVERSION=\"0.01\" -DXS_VERSION=\"0.01\" -fPIC "-I/home/vince/perl/builds/64/5.14.1/lib/5.14.1/x86_64-linux/CORE" Wut.c rm -f blib/arch/auto/Wut/Wut.so cc -shared -march=core2 -O3 -fomit-frame-pointer -ftree-vectorize -ftree-vectorizer-verbose=1 -pipe -DNDEBUG -L/usr/local/lib -fstack-protector Wut.o -fprofile-arcs -ftest-coverage -o blib/arch/auto/Wut/Wut.so \ \ chmod 755 blib/arch/auto/Wut/Wut.so PERL_DL_NONLAZY=1 /home/vince/perl/builds/64/5.14.1/bin/perl5.14.1 "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/try.t .. ok All tests successful. Files=1, Tests=2, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.20 cusr 0.01 csys = 0.23 CPU) Result: PASS cover: running gcov -abc -o . Wut.c File 'Wut.c' Lines executed:93.33% of 15 Branches executed:100.00% of 3 Taken at least once:33.33% of 3 No calls Wut.c:creating 'Wut.c.gcov' File 'Wut.xs' Lines executed:100.00% of 2 Branches executed:100.00% of 3 Taken at least once:66.67% of 3 No calls Wut.xs:creating 'Wut.xs.gcov' cover: running gcov -abc -o . Wut.xs File 'Wut.c' Lines executed:93.33% of 15 Branches executed:100.00% of 3 Taken at least once:33.33% of 3 No calls Wut.c:creating 'Wut.c.gcov' File 'Wut.xs' Lines executed:100.00% of 2 Branches executed:100.00% of 3 Taken at least once:66.67% of 3 No calls Wut.xs:creating 'Wut.xs.gcov' cover: running gcov2perl -db /home/vince/perl/Wut/cover_db Wut.xs.gcov gcov2perl: Writing coverage database to /home/vince/perl/Wut/cover_db/runs/1312720103.12867.12875 Reading database from /home/vince/perl/Wut/cover_db found cover.12 in /home/vince/perl/Wut/cover_db/runs/1312720103.12867.12875 at /home/vince/perl/builds/64/5.14.1/lib/site_perl/5.14.1/x86_64-linux/Devel/Cover/DB.pm line 192. Devel::Cover: /home/vince/perl/Wut/cover_db/runs/1312720103.12867.12875 is an invalid database malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "pst0\x{5}\a\x{3}\x{0}...") at /home/vince/perl/builds/64/5.14.1/lib/site_perl/5.14.1/x86_64-linux/Devel/Cover/DB/IO/JSON.pm line 33 ============================================================
Subject: Wut-0.01.tar.gz
Download Wut-0.01.tar.gz
application/gzip 9.3k

Message body not shown because it is not plain text.

For the record, we found on IRC that this happened because cover just runs the first "gcov2perl" in the PATH, which may be different from the gcov2perl that is associated with the current version of cover. A proposed fix is attached. Vincent
Subject: devel_cover_find_gcov2perl.patch
--- cover.orig 2011-08-07 17:31:31.000000000 +0200 +++ cover 2011-08-07 17:36:51.000000000 +0200 @@ -254,7 +254,12 @@ File::Find::find({ wanted => $gp, no_chdir => 1 }, "."); if (@gc) { - my $c = "gcov2perl -db $dbname @gc"; + # Find the right gcov2perl based on this current script. + require Cwd; + my $cover = Cwd::abs_path($0); + my ($vol, $dir, $cover) = File::Spec->splitpath($cover); + my $gcov2perl = File::Spec->catpath($vol, $dir, 'gcov2perl'); + my $c = "$gcov2perl -db $dbname @gc"; print STDERR "cover: running $c\n"; system $c; }
Thanks very much for this report. Looks like I forgot to close the ticket after applying the patch as e42aee26 so I'll do it now. Thanks again.