This is an archive of the discontinued LLVM Phabricator instance.

Try to fix buildbot failure in VirtualFileSystem caused by r284129.
AbandonedPublic

Authored by ioeric on Oct 14 2016, 2:12 AM.

Details

Reviewers
bruno
bkramer
Summary

Since remove_dots does not delete leading "../" anymore, assertion test need
to be updated.

Event Timeline

ioeric updated this revision to Diff 74630.Oct 14 2016, 2:12 AM
ioeric retitled this revision from to Try to fix buildbot failure in VirtualFileSystem caused by r284129..
ioeric updated this object.
ioeric added a reviewer: bkramer.
ioeric added a subscriber: cfe-commits.
ioeric updated this revision to Diff 74631.Oct 14 2016, 2:16 AM
  • Separate assertions to get more information.
bkramer edited edge metadata.

I think the assertion is correct, there's something fishy with the inputs. The paths coming in should be absolute, and there should never be a .. at the start in a absolute path. This only fails on a single buildbot and doesn't reproduce anywhere else. @bruno any ideas?

bruno edited edge metadata.Oct 14 2016, 1:12 PM

One possible reason: remove_dots is called upon a path with a leading "..", which then gets appended in front of another path to form the absolute path. I'm taking a look right now to try to figure out if there's any code path that might lead to this.

dbgs showed that the path components were .. target hexagon include.
The paths are constructed in lib/Driver/ToolChains.cpp, many are based on "getHexagonTargetDir".

bruno added a comment.Oct 14 2016, 1:43 PM

Krzysztof, do you have a backtrace that you can paste here or point me to the buidbot stderr log? There's no point in looking for relative paths inside the VFS, it would be nice if we fix the root cause here.

Right on entry to the asserting function:

(gdb) where
#0  0x00007ffff52b9870 in (anonymous namespace)::RedirectingFileSystem::lookupPath(llvm::sys::path::const_iterator, llvm::sys::path::const_iterator, (anonymous namespace)::Entry*) () from /w/bld/up/bin/../lib/libclang.so.40
#1  0x00007ffff52b9b8c in (anonymous namespace)::RedirectingFileSystem::lookupPath(llvm::sys::path::const_iterator, llvm::sys::path::const_iterator, (anonymous namespace)::Entry*) () from /w/bld/up/bin/../lib/libclang.so.40
#2  0x00007ffff52b929f in (anonymous namespace)::RedirectingFileSystem::lookupPath(llvm::Twine const&) () from /w/bld/up/bin/../lib/libclang.so.40
#3  0x00007ffff52b836c in (anonymous namespace)::RedirectingFileSystem::status(llvm::Twine const&) () from /w/bld/up/bin/../lib/libclang.so.40
#4  0x00007ffff52b2171 in clang::vfs::OverlayFileSystem::status(llvm::Twine const&) () from /w/bld/up/bin/../lib/libclang.so.40
#5  0x00007ffff5292691 in clang::FileSystemStatCache::get(llvm::StringRef, clang::FileData&, bool, std::__1::unique_ptr<clang::vfs::File, std::__1::default_delete<clang::vfs::File> >*, clang::FileSystemStatCache*, clang::vfs::FileSystem&)
    () from /w/bld/up/bin/../lib/libclang.so.40
#6  0x00007ffff528f523 in clang::FileManager::getStatValue(llvm::StringRef, clang::FileData&, bool, std::__1::unique_ptr<clang::vfs::File, std::__1::default_delete<clang::vfs::File> >*) () from /w/bld/up/bin/../lib/libclang.so.40
#7  0x00007ffff528f326 in clang::FileManager::getDirectory(llvm::StringRef, bool) () from /w/bld/up/bin/../lib/libclang.so.40
#8  0x00007ffff5323e23 in (anonymous namespace)::InitHeaderSearch::AddUnmappedPath(llvm::Twine const&, clang::frontend::IncludeDirGroup, bool) ()
   from /w/bld/up/bin/../lib/libclang.so.40
#9  0x00007ffff5323133 in clang::ApplyHeaderSearchOptions(clang::HeaderSearch&, clang::HeaderSearchOptions const&, clang::LangOptions const&, llvm::Triple const&) () from /w/bld/up/bin/../lib/libclang.so.40
#10 0x00007ffff52dc120 in clang::CompilerInstance::createPreprocessor(clang::TranslationUnitKind) () from /w/bld/up/bin/../lib/libclang.so.40
#11 0x00007ffff531d0a7 in clang::FrontendAction::BeginSourceFile(clang::CompilerInstance&, clang::FrontendInputFile const&) ()
   from /w/bld/up/bin/../lib/libclang.so.40
#12 0x00007ffff52ccc90 in clang::ASTUnit::LoadFromCompilerInvocationAction(clang::CompilerInvocation*, std::__1::shared_ptr<clang::PCHContainerOperations>, llvm::IntrusiveRefCntPtr<clang::DiagnosticsEngine>, clang::FrontendAction*, clang::ASTUnit*, bool, llvm::StringRef, bool, bool, unsigned int, bool, bool, bool, std::__1::unique_ptr<clang::ASTUnit, std::__1::default_delete<clang::ASTUnit> >*)
    () from /w/bld/up/bin/../lib/libclang.so.40
#13 0x00007ffff507e1b6 in clang_indexSourceFileFullArgv::$_0::operator()() const () from /w/bld/up/bin/../lib/libclang.so.40
#14 0x00007ffff5c22271 in llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) () from /w/bld/up/bin/../lib/libclang.so.40
#15 0x00007ffff5c223b4 in RunSafelyOnThread_Dispatch(void*) ()
   from /w/bld/up/bin/../lib/libclang.so.40
#16 0x00007ffff5c6d3fa in ExecuteOnThread_Dispatch(void*) ()
   from /w/bld/up/bin/../lib/libclang.so.40
#17 0x00007ffff797d182 in start_thread (arg=0x7ffff3234700)
    at pthread_create.c:312
#18 0x00007ffff3b3047d in clone ()
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

(gdb) cont
Continuing.
..:target:hexagon:include:
c-index-test: /w/src/llvm.org/tools/clang/lib/Basic/VirtualFileSystem.cpp:1485: ErrorOr<(anonymous namespace)::Entry *> (anonymous namespace)::RedirectingFileSystem::lookupPath(sys::path::const_iterator, sys::path::const_iterator, (anonymous namespace)::Entry *): Assertion `!isTraversalComponent(*Start) && !isTraversalComponent(From->getName()) && "Paths should not contain traversal components"' failed.

Program received signal SIGABRT, Aborted.
0x00007ffff3a6ccc9 in __GI_raise (sig=sig@entry=6)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56      ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.

The ..:target:hexagon:include: is debug code printing all the path components, separated by :.

bruno added a comment.Oct 14 2016, 6:40 PM

Looks that somehow the current directory doesn't exit anymore OR it's non empty but only contains spaces or something like that. Besides the snippet below, RedirectingFileSystem::lookupPath(llvm::Twine const&) also calls makeAbsolute before remove_dots. Can you try to print FileSystemOpts.WorkingDir?

                                                                                                                                                                                                                           
bool FileManager::getStatValue(StringRef Path, FileData &Data, bool isFile,                                                                                                                                                                                                   
                             std::unique_ptr<vfs::File> *F) {                                                                                                                                                                                                               
// FIXME: FileSystemOpts shouldn't be passed in here, all paths should be                                                                                                                                                                                                   
// absolute!                                                                                                                                                                                                                                                                
if (FileSystemOpts.WorkingDir.empty())                                                                                                                                                                                                                                      
  return FileSystemStatCache::get(Path, Data, isFile, F,StatCache.get(), *FS);                                                                                                                                                                                              
                                                                                                                                                                                                                                                                            
SmallString<128> FilePath(Path);                                                                                                                                                                                                                                            
FixupRelativePath(FilePath);                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                            
return FileSystemStatCache::get(FilePath.c_str(), Data, isFile, F,                                                                                                                                                                                                          
                                StatCache.get(), *FS);

}

This change

bool FileManager::getStatValue(StringRef Path, FileData &Data, bool isFile,
                               std::unique_ptr<vfs::File> *F) {
  // FIXME: FileSystemOpts shouldn't be passed in here, all paths should be
  // absolute!
llvm::dbgs() << "FileSystemOpts.WorkingDir: '" << FileSystemOpts.WorkingDir << "'\n";
  if (FileSystemOpts.WorkingDir.empty())
    return FileSystemStatCache::get(Path, Data, isFile, F,StatCache.get(), *FS);

prints
FileSystemOpts.WorkingDir: ''

FileSystemOpts.WorkingDir: ''

There is no space between the single quotes.

Printing Path shows
/../target/hexagon/include

I committed https://reviews.llvm.org/rL284383 and the Hexagon bot is passing now. (The patch was reverted, but then it was recommitted.)

Nice! Thanks

ioeric abandoned this revision.Oct 19 2016, 8:20 AM

Thanks all!