Testing perl with Valgrind

Since there isn't much I've noticed blogged about the perl interpreter itself, I'll add some notes that could be of interest. In particular, like CPAN Testers, there are some people contributing tests of perl itself albeit with a lower profile and without the snazzy web site. Toward the goal of testing, I made a post to revive the "make test.valgrind" capability perl had:

Attached patch fixes 'make test.valgrind' to handle cpan/dist/ext directories. I changed the temporary output name from "current.valgrind" to "$test.valgrind-current" in the hopes that it won't die under harness with TEST_JOBS, although I didn't test that way. The permanent output is still "$test.valgrind".

Note that t/op/magic.c, test 38 ($0 set testing), seems to always fail under valgrind:

- - - 8< - - - 8< - - -
t/op/magic.....................................................# Failed at op/magic.t line 332
# got "./perl"
# expected "bar"
FAILED at test 38
- - - 8< - - - 8< - - -

Failed 1 test out of 1706, 99.94% okay.
op/magic.t
u=17.19 s=5.74 cu=33851.49 cs=318.62 scripts=1706 tests=353737

Due to the speed (or lack thereof) of valgrind runs, I'll probably set up a separate "smoke" job (no Test::Smoke) to upload the reports.

For those wanting a spoiler of the results:

  • Pages and pages and pages of varying degress of lost memory.

  • Syscall param utimes(tvp[1]) points to uninitialised byte(s)
    [utimes (utimes.c:33)]

  • Conditional jump or move depends on uninitialised value(s)
    [S_nextchar (regcomp.c:8569) from malloc (vg_replace_malloc.c:236)]
    [inflate (inflate.c:1229) from crc32_little (crc32.c:291)]
    [inflate (inflate.c:1169) from malloc (vg_replace_malloc.c:236)]
    [inflate (inflate.c:1167) from malloc (vg_replace_malloc.c:236)]
    [adler32 (adler32.c:93) from malloc (vg_replace_malloc.c:236)]
    [adler32 (adler32.c:75) from malloc (vg_replace_malloc.c:236)]
    [S_uiv_2buf (sv.c:2710) << Perl_sv_2pv_flags (sv.c:2945)]
    [S_uiv_2buf (sv.c:2719) << Perl_sv_2pv_flags (sv.c:2945)]
    [bcmp (mc_replace_strmem.c:541) << Perl_sv_eq (sv.c:6735)]

  • Use of uninitialised value of size 8
    [crc32_little (crc32.c:281) from malloc (vg_replace_malloc.c:236)]
    [crc32_little (crc32.c:291) from malloc (vg_replace_malloc.c:236)]

  • Warning: bad signal number 0 in sigaction()

And likely way more because I made the above list by hand. If anybody wishes to investigate any of the above in the meantime, see my web repository.

I'll try to dig through them myself as time (and skill) permits.

In case you don't know what Valgrind is, or why I would want to run tests on perl with it, there's a Valgrind web site.

Leave a comment

About George Greer

user-pic Data swizzling practitioner.