[LLVMbugs] [Bug 14061] New: scan-build crashes during postprocessing if BUGFILE no longer exists

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Oct 10 22:51:29 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=14061

             Bug #: 14061
           Summary: scan-build crashes during postprocessing if BUGFILE no
                    longer exists
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
        AssignedTo: kremenek at apple.com
        ReportedBy: matti.niemenmaa+llvmbugs at iki.fi
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


If a file in which the static analyzer found a bug no longer exists when
scan-build does its postprocessing over the report* files, scan-build exits
unceremoniously with a message like the following:


Use of uninitialized value $_[0] in substitution (s///) at
/usr/share/perl5/core_perl/File/Basename.pm line 341, <IN> line 63.
fileparse(): need a valid pathname at /path/to/scan-build line 247


The root cause is abs_path returning undef if the path no longer exists. I
propose the following simple fix (patch based on the git mirror but simple
enough):


diff --git i/tools/scan-build/scan-build w/tools/scan-build/scan-build
index a13b235..3ed6e3f 100755
--- i/tools/scan-build/scan-build
+++ w/tools/scan-build/scan-build
@@ -363,6 +363,10 @@ sub ScanFile {
     }
     elsif (/<!-- BUGFILE (.*) -->$/) {
       $BugFile = abs_path($1);
+      if (!defined $BugFile) {
+         # The file no longer exists: use the original path.
+         $BugFile = $1;
+      }
       UpdatePrefix($BugFile);
     }
     elsif (/<!-- BUGPATHLENGTH (.*) -->$/) {


I ran into this whilst using the tup build system ( http://gittup.org/tup/ ),
which uses temporary FUSE file systems to determine what files are accessed by
the compiler. Thus I'd end up with BUGFILE lines such as:

<!-- BUGFILE /path/to/project/.tup/mnt/@tupjob-1234/path/to/project/src.c -->

Handling those properly would require some tup-specific recognition in
scan-build and most likely isn't worth the trouble, but fixing the crash might
be helpful for other situations as well. (E.g. somebody inadvertently removes a
source file while scan-build is still running and then doesn't get an
index.html for the scan-build run that took an hour?)

As an aside, the UpdatePrefix function seems to be a bit greedy: it doesn't
compute the common path, it goes specifically for the common prefix. I noticed
that it removes the '@tupjob-' part for my files, so it seems that if all my
source files started with the letter 'a' it would chop off that 'a' when
showing the path in index.html. Maybe it should only compute prefixes that end
with a directory separator.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list