From: Vincent Pit Date: Thu, 12 Nov 2015 12:19:02 +0000 (-0200) Subject: Handle segfaults during suppressions generation gracefully X-Git-Tag: v1.16~7 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=39af0cb1411f565d286cd656a7a0bdd3d3ba07fb;p=perl%2Fmodules%2FTest-Valgrind.git Handle segfaults during suppressions generation gracefully --- diff --git a/lib/Test/Valgrind/Action/Suppressions.pm b/lib/Test/Valgrind/Action/Suppressions.pm index c100771..6c34860 100644 --- a/lib/Test/Valgrind/Action/Suppressions.pm +++ b/lib/Test/Valgrind/Action/Suppressions.pm @@ -155,7 +155,8 @@ sub finish { open my $fh, '>', $target or $self->_croak("open(\$fh, '>', \$self->target): $!"); - my (%seen, $id); + my $id = 0; + my %seen; for (sort { $a->data cmp $b->data } grep !$seen{$_->data}++, @{$self->{supps}}) { print $fh "{\n" diff --git a/lib/Test/Valgrind/Parser.pm b/lib/Test/Valgrind/Parser.pm index 1101715..8e89953 100644 --- a/lib/Test/Valgrind/Parser.pm +++ b/lib/Test/Valgrind/Parser.pm @@ -55,9 +55,10 @@ sub args { } =head2 C - $tvp->parse($session, $fh); + my $aborted = $tvp->parse($session, $fh); -Parse the output of the C process attached to the session C<$session> received through the filehandle C<$fh>. +Parses the output of the C process attached to the session C<$session> received through the filehandle C<$fh>. +Returns true when the output indicates that C has aborted. This method must be implemented when subclassing. diff --git a/lib/Test/Valgrind/Parser/Suppressions/Text.pm b/lib/Test/Valgrind/Parser/Suppressions/Text.pm index 7692e83..7710e52 100644 --- a/lib/Test/Valgrind/Parser/Suppressions/Text.pm +++ b/lib/Test/Valgrind/Parser/Suppressions/Text.pm @@ -45,7 +45,13 @@ sub parse { while (<$fh>) { s/^\s*#\s//; # Strip comments - next if /^==/; # Valgrind info line + if (/^==/) { # Valgrind info line + if (/Signal 11 being dropped from thread/) { + # This might loop endlessly + return 1; + } + next; + } s/^\s*//; # Strip leading spaces s/<[^>]+>//; # Strip tags @@ -103,6 +109,8 @@ sub parse { kind => 'Suppression', data => $_, )) for @supps, @extra; + + return 0; } =head1 SEE ALSO diff --git a/lib/Test/Valgrind/Parser/XML/Twig.pm b/lib/Test/Valgrind/Parser/XML/Twig.pm index 59801de..c58cf10 100644 --- a/lib/Test/Valgrind/Parser/XML/Twig.pm +++ b/lib/Test/Valgrind/Parser/XML/Twig.pm @@ -86,7 +86,7 @@ sub parse { $self->protocol_version(undef); - return; + return 0; } sub finish { diff --git a/lib/Test/Valgrind/Session.pm b/lib/Test/Valgrind/Session.pm index da71b78..b0069df 100644 --- a/lib/Test/Valgrind/Session.pm +++ b/lib/Test/Valgrind/Session.pm @@ -345,7 +345,9 @@ sub run { close $vwtr or $self->_croak("close(\$vwtr): $!"); - $self->parser->parse($self, $vrdr); + my $aborted = $self->parser->parse($self, $vrdr); + + kill -(POSIX::SIGKILL()) => $pid if $aborted; $self->{exit_code} = (waitpid($pid, 0) == $pid) ? $? >> 8 : 255;