[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[SCM] Debian package checker branch, master, updated. 2.5.10-167-g8492e7d



The following commit has been merged in the master branch:
commit 8492e7dce2ff5dd65955e0437d9bb42f07503e11
Author: Niels Thykier <niels@thykier.net>
Date:   Mon Sep 24 22:55:37 2012 +0200

    L::Command: Work around memory leak in IPC::Run
    
    By default, spawn will set the child's "STDIN" to ("<", \undef).
    Unfortunately, SCALAR refs are leaked (even the undef case) so this
    translates to a "leak by default".
    
    The work around is to translate ("<", \undef) to ("<&-"), which
    doesn't leak.  Though, this only fixes the default case, so the leak
    is only fixed as long as SCALAR ref remain unused in Lintian.
    
    According to [1] about 2KB are lost per leak.  Ignoring the
    "short-lived" collections, this means a 4KB leak per deb-format check
    and a leak for every "delete_dir" (Lab and Lab entry removals).
    
    [1] https://rt.cpan.org/Public/Bug/Display.html?id=13660
    
    Debian bug: #301774
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/debian/changelog b/debian/changelog
index 3647afc..c954d23 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -163,6 +163,8 @@ lintian (2.5.11) UNRELEASED; urgency=low
       conffile.
   * lib/Lintian/Collect/Package.pm:
     + [NT] Strip leading slash off files extracted from tar.
+  * lib/Lintian/Command.pm:
+    + [NT] Work around a leak in IPC::Run (see #301774).
   * lib/Lintian/Internal/FrontendUtil.pm:
     + [NT] Always use Dpkg::Vendor to determine the default
       vendor.  Previously dpkg-vendor would be preferred if
diff --git a/lib/Lintian/Command.pm b/lib/Lintian/Command.pm
index cdb6f26..a63e043 100644
--- a/lib/Lintian/Command.pm
+++ b/lib/Lintian/Command.pm
@@ -86,6 +86,10 @@ The following hash keys can be set to alter the behaviour of spawn():
 
 STDIN for the first forked child.  Defaults to C<\undef>.
 
+CAVEAT: Due to #301774, passing a SCALAR ref as STDIN for the child
+leaks memory.  The leak is plugged for the C<\undef> case in spawn,
+but other scalar refs may still be leaked.
+
 =item pipe_in
 
 Use a pipe for STDIN and start the process in the background.
@@ -175,8 +179,16 @@ sub spawn {
         @in = ('<pipe', $opts->{pipe_in});
         $background = 1;
     } else {
-        $opts->{in} ||= \undef;
-        @in = ('<', $opts->{in});
+        # ("<", \$ref) leaks memory, but ("<&-") doesn't (see #301774)
+        #
+        # We plug the \undef case here because it has a trivial work
+        # around and it is the default value.
+        my $in = $opts->{in};
+        if (not defined $in or (ref $in eq 'SCALAR' and not defined $$in)) {
+            @in = ('<&-');
+        } else {
+            @in = ('<', $opts->{in});
+        }
     }
     if ($opts->{pipe_out}) {
         @out = ('>pipe', $opts->{pipe_out});

-- 
Debian package checker


Reply to: