diff options
author | kush <kush@google.com> | 2017-08-30 00:27:35 +0200 |
---|---|---|
committer | Vladimir Moskva <vladmos@google.com> | 2017-08-30 13:48:40 +0200 |
commit | 95bf7c89064d6871615f2b6211b9de4575d38b51 (patch) | |
tree | c5db1d9652352a39f419e73d055c6010f018dc12 /src/main | |
parent | 00443495e002c9fc68adbcb708f223eb4b6a73c1 (diff) |
Stop blaze crash due to a symlink cycle or unbounded expansion encountered
while traversing filesets.
RELNOTES: None
PiperOrigin-RevId: 166913262
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunction.java | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunction.java index e122307ee7..50ae176a49 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunction.java @@ -31,6 +31,7 @@ import com.google.devtools.build.skyframe.SkyFunction; import com.google.devtools.build.skyframe.SkyFunctionException; import com.google.devtools.build.skyframe.SkyKey; import com.google.devtools.build.skyframe.SkyValue; +import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -97,6 +98,13 @@ public final class RecursiveFilesystemTraversalFunction implements SkyFunction { } } + /** Thrown when we encounter errors from underlying File operations */ + public static final class FileOperationException extends RecursiveFilesystemTraversalException { + public FileOperationException(String message) { + super(message); + } + } + /** Exception type thrown by {@link RecursiveFilesystemTraversalFunction#compute}. */ private static final class RecursiveFilesystemTraversalFunctionException extends SkyFunctionException { @@ -166,6 +174,9 @@ public final class RecursiveFilesystemTraversalFunction implements SkyFunction { // We are free to traverse this directory. Collection<SkyKey> dependentKeys = createRecursiveTraversalKeys(env, traversal); return resultForDirectory(traversal, rootInfo, traverseChildren(env, dependentKeys)); + } catch (FileSymlinkException | InconsistentFilesystemException | IOException e) { + throw new RecursiveFilesystemTraversalFunctionException( + new FileOperationException("Error while traversing fileset: " + e.getMessage())); } catch (MissingDepException e) { return null; } @@ -202,9 +213,20 @@ public final class RecursiveFilesystemTraversalFunction implements SkyFunction { } private static FileInfo lookUpFileInfo(Environment env, TraversalRequest traversal) - throws MissingDepException, InterruptedException { + throws MissingDepException, FileSymlinkException, InconsistentFilesystemException, + IOException, InterruptedException { // Stat the file. - FileValue fileValue = (FileValue) getDependentSkyValue(env, FileValue.key(traversal.path)); + FileValue fileValue = + (FileValue) + env.getValueOrThrow( + FileValue.key(traversal.path), + FileSymlinkException.class, + InconsistentFilesystemException.class, + IOException.class); + + if (env.valuesMissing()) { + throw new MissingDepException(); + } if (fileValue.exists()) { // If it exists, it may either be a symlink or a file/directory. PathFragment unresolvedLinkTarget = null; @@ -279,7 +301,8 @@ public final class RecursiveFilesystemTraversalFunction implements SkyFunction { */ private static PkgLookupResult checkIfPackage( Environment env, TraversalRequest traversal, FileInfo rootInfo) - throws MissingDepException, InterruptedException { + throws MissingDepException, FileSymlinkException, InconsistentFilesystemException, + IOException, InterruptedException { Preconditions.checkArgument(rootInfo.type.exists() && !rootInfo.type.isFile(), "{%s} {%s}", traversal, rootInfo); PackageLookupValue pkgLookup = (PackageLookupValue) getDependentSkyValue(env, |