Revision: 1341
Author: [email protected]
Date: Sun Sep 12 03:24:36 2010
Log: Protect against bad line numbers (eg -1 being treated as 4294967295) hanging report generation.

http://code.google.com/p/perl-devel-nytprof/source/detail?r=1341

Modified:
 /trunk/lib/Devel/NYTProf/Reader.pm

=======================================
--- /trunk/lib/Devel/NYTProf/Reader.pm  Thu Jul  8 07:10:06 2010
+++ /trunk/lib/Devel/NYTProf/Reader.pm  Sun Sep 12 03:24:36 2010
@@ -228,18 +228,25 @@
# note that a file may have no source lines executed, so no keys here
         # (but is included because some xsubs in the package were executed)
         my $lines_array = $fi->line_time_data([$LEVEL]) || [];
+        my $src_max_line = scalar @$lines_array;
+
+ for ($src_max_line, $subcalls_max_line, $subdefs_max_line, $evals_max_line) {
+            next if $_ < 2**16;
+ warn "Ignoring indication that $filestr has $_ lines! (Possibly corrupt data)\n";
+            $_ = 0;
+        }

         my $max_linenum = max(
-            scalar @$lines_array,
+            $src_max_line,
             $subcalls_max_line,
             $subdefs_max_line,
             $evals_max_line,
         );

- warn sprintf "%s %s max lines: stmts %d, subcalls %d, subdefs %d, evals %d\n",
-                $filestr, $LEVEL, scalar @$lines_array,
+ warn sprintf "%s max lines: %s (stmts %s, subcalls %s, subdefs %s, evals %s)\n",
+                $filestr, $max_linenum, scalar @$lines_array,
                 $subcalls_max_line, $subdefs_max_line, $evals_max_line
-            if trace_level() >= 4;
+            if trace_level() >= 4 or $max_linenum > 2**15;

my %stats_accum; # holds all line times. used to find median
         my %stats_by_line;         # holds individual line stats

--
You've received this message because you are subscribed to
the Devel::NYTProf Development User group.

Group hosted at:  http://groups.google.com/group/develnytprof-dev
Project hosted at:  http://perl-devel-nytprof.googlecode.com
CPAN distribution:  http://search.cpan.org/dist/Devel-NYTProf

To post, email:  [email protected]
To unsubscribe, email:  [email protected]

Reply via email to