Subject: | t/050interop-xz.t may fail (memory leak?) |
On a few of my smokers the test suite fails like in this report:
http://www.cpantesters.org/cpan/report/ba2d8f26-11ca-11e9-b3e9-cc477c15f8a6
What's strange here: apparently system("xz ...") did not return 0, but $? is zero, as the diag() output following the system() call shows.
I could not reproduce the failure outside of CPAN.pm, e.g. using "perl -Mblib t/050interop-xz.t" or "make test". But I could reproduce it with "cpan -t .". An strace log shows the following line:
19814 20:48:51.556543 clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f2d96c5e590) = -1 ENOMEM (Cannot allocate memory) <0.027514>
So this would explain why it only fails under CPAN.pm: with CPAN.pm some ~350MB are already consumed and not available anymore (this is a Debian/stretch VM with 1.6GB RAM).
For further debugging I put a process memory calculation function into the test script ( https://github.com/eserte/srezic-repository/blob/master/perl/currmem#L14 ) and this is the output:
t/050interop-xz.t .... 1/1006 151035904,107311104 at t/050interop-xz.t line 205.
151175168,107450368 at t/050interop-xz.t line 205.
117620736,73895936 at t/050interop-xz.t line 205.
151175168,107450368 at t/050interop-xz.t line 205.
151175168,107450368 at t/050interop-xz.t line 205.
151175168,107450368 at t/050interop-xz.t line 205.
168226816,124502016 at t/050interop-xz.t line 205.
t/050interop-xz.t .... 54/1006 168226816,124502016 at t/050interop-xz.t line 205.
168226816,124502016 at t/050interop-xz.t line 205.
168226816,124502016 at t/050interop-xz.t line 205.
134672384,90947584 at t/050interop-xz.t line 205.
134672384,90947584 at t/050interop-xz.t line 205.
168226816,124502016 at t/050interop-xz.t line 205.
168226816,124502016 at t/050interop-xz.t line 205.
168226816,124502016 at t/050interop-xz.t line 205.
101113856,57389056 at t/050interop-xz.t line 205.
101113856,57389056 at t/050interop-xz.t line 205.
101113856,57389056 at t/050interop-xz.t line 205.
101113856,57389056 at t/050interop-xz.t line 205.
134672384,90947584 at t/050interop-xz.t line 205.
168226816,124502016 at t/050interop-xz.t line 205.
168226816,124502016 at t/050interop-xz.t line 205.
294866944,251142144 at t/050interop-xz.t line 205.
487804928,444080128 at t/050interop-xz.t line 205.
806572032,762847232 at t/050interop-xz.t line 205.
# '/usr/bin/xz -dc -F xz' failed: 0
# Failed test (t/050interop-xz.t at line 207)
# Failed test (t/050interop-xz.t at line 208)
... (etc) ...
I assume that a fork (or clone) requires the same amount of memory as already used, so another ~800MB to the existing ~800MB is needed here. And it looks like there's a lot of memory consumption before the first test failure.
(Another question is: why doesn't system() return -1 in this situation?)