b=647469 continue after crashes in addr2line r=dbaron
authorKarl Tomlinson <karlt+@karlt.net>
Mon, 02 May 2011 08:33:16 +1200
changeset 69248 d77a997768a923b74dbb35984eca676ed5c05b44
parent 69247 615cffa67cfaef8c9ee695bfaa5ec3eaa1bc5c02
child 69249 3865e976d54de27d5c54e718a4f5230f46692a79
push idunknown
push userunknown
push dateunknown
reviewersdbaron
bugs647469
milestone6.0a1
b=647469 continue after crashes in addr2line r=dbaron
config/preprocessor.pl
tools/rb/fix-linux-stack.pl
old mode 100644
new mode 100755
--- a/tools/rb/fix-linux-stack.pl
+++ b/tools/rb/fix-linux-stack.pl
@@ -238,16 +238,19 @@ sub addr2line_pipe($) {
                         '/usr/bin/addr2line', '-C', '-f', '-e', $debug_file);
         $pipes{$file} = $pipe;
     } else {
         $pipe = $pipes{$file};
     }
     return $pipe;
 }
 
+# Ignore SIGPIPE as a workaround for addr2line crashes in some situations.
+$SIG{PIPE} = 'IGNORE';
+
 select STDOUT; $| = 1; # make STDOUT unbuffered
 while (<>) {
     my $line = $_;
     if ($line =~ /^([ \|0-9-]*)(.*) ?\[([^ ]*) \+(0x[0-9A-F]{1,8})\](.*)$/) {
         my $before = $1; # allow preservation of balance trees
         my $badsymbol = $2;
         my $file = $3;
         my $address = hex($4);
@@ -257,18 +260,20 @@ while (<>) {
             my $pipe = addr2line_pipe($file);
             $address += address_adjustment($file);
 
             my $out = $pipe->{write};
             my $in = $pipe->{read};
             printf {$out} "0x%X\n", $address;
             chomp(my $symbol = <$in>);
             chomp(my $fileandline = <$in>);
-            if ($symbol eq '??') { $symbol = $badsymbol; }
-            if ($fileandline eq '??:0') { $fileandline = $file; }
+            if (!$symbol || $symbol eq '??') { $symbol = $badsymbol; }
+            if (!$fileandline || $fileandline eq '??:0') {
+                $fileandline = $file;
+            }
             print "$before$symbol ($fileandline)$after\n";
         } else {
             print STDERR "Warning: File \"$file\" does not exist.\n";
             print $line;
         }
 
     } else {
         print $line;