]> git.vpit.fr Git - perl/modules/Test-Valgrind.git/commitdiff
Make sure suppressions don't contain more than 24 frames
authorVincent Pit <perl@profvince.com>
Fri, 29 Jul 2016 16:46:20 +0000 (13:46 -0300)
committerVincent Pit <perl@profvince.com>
Fri, 29 Jul 2016 16:46:23 +0000 (13:46 -0300)
Or valgrind will panic because 24 suppressions frames should be enough for
everyone!

lib/Test/Valgrind/Suppressions.pm

index f5f576a676f71b6a8b1b53017c5d4884fafe89a0..8e90ab7b87ddab5227e2be0ff98a950120535ac9 100644 (file)
@@ -115,9 +115,28 @@ sub maybe_generalize {
  1 while $supp =~ s/[^\r\n]*:\s*\*\s*$//;
 
  # With valgrind 3.4.0, we can replace unknown series of frames by '...'
  1 while $supp =~ s/[^\r\n]*:\s*\*\s*$//;
 
  # With valgrind 3.4.0, we can replace unknown series of frames by '...'
- if ($sess->version >= '3.4.0') {
-  $supp .= "...\n";
-  $supp =~ s/(?:^\s*(?:\.{3}|\*:\S*|obj:\*)\s*(?:\n|\z))+/...\n/mg;
+ my $can_ellipsis = $sess->version >= '3.4.0';
+
+ my $did_length_check;
+
+ ELLIPSIS: {
+  if ($can_ellipsis) {
+   $supp .= "...\n";
+   $supp =~ s/(?:^\s*(?:\.{3}|\*:\S*|obj:\*)\s*(?:\n|\z))+/...\n/mg;
+  }
+
+  last if $did_length_check++;
+
+  my $frames_count =()= $supp =~ m/^(?:(?:obj|fun|\*):|\.{3}\s*$)/mg;
+  if ($frames_count > 24) {
+   # Keep only 24 frames, and even sacrifice one more if we can do ellipsis.
+   my $last = $can_ellipsis ? 23 : 24;
+   my $len  = length $supp;
+   $supp    =~ m/^(?:(?:obj|fun|\*):\S*|\.{3})\s*\n/mg for 1 .. $last;
+   my $p    = pos $supp;
+   substr $supp, $p, $len - $p, '';
+   redo ELLIPSIS if $can_ellipsis;
+  }
  }
 
  $supp;
  }
 
  $supp;