Hi,
I'm involved with a project that's using clang to index source files and I'm
currently having strange crashes in calls to clang_reparseTranslationUnit,
this seemingly happens both in Clang 3.2 and trunk as of r180688. The
program is running multiple threads, if I never do a reparse but always do a
full parse from source then I don't see any crashes. I've verified that no
other threads are touching the same unit when this happens.
It's not trivial to reproduce, and I've only ever seen it when multiple
threads are calling into clang at the same time and the source code at the
same time is not compiling.
Are there any known problems with clang_reparseTranslationUnit and calling
that from multiple threads at the same time?
Thanks!
I have some more information for my problem, the crash seemingly only happens when the program is calling clang_reparseTranslationUnit and the source file is being changed from a different process at the exact same time. Does reparsing require passing the source file as a CXUnsavedFile? If so, does that only go for the main source file or does it apply for all included files as well?
These are the first few frames of what gdb tells me when the program crashes,
#0 0x00007ffff5aef423 in ComputeLineNumbers(clang::DiagnosticsEngine&, clang::SrcMgr::ContentCache*, llvm::BumpPtrAllocator&, clang::SourceManager const&, bool&) () from /usr/local/clang-3.3/lib/libclang.so
#1 0x00007ffff5aef15d in clang::SourceManager::getLineNumber(clang::FileID, unsigned int, bool*) const () from /usr/local/clang-3.3/lib/libclang.so
#2 0x00007ffff5aeef64 in clang::SourceManager::getPresumedLoc(clang::SourceLocation, bool) const () from /usr/local/clang-3.3/lib/libclang.so
#3 0x00007ffff5abffe8 in clang::Preprocessor::ExpandBuiltinMacro(clang::Token&) () from /usr/local/clang-3.3/lib/libclang.so
#4 0x00007ffff5abf659 in clang::Preprocessor::HandleMacroExpandedIdentifier(clang::Token&, clang::MacroDirective*) () from /usr/local/clang-3.3/lib/libclang.so
#5 0x00007ffff5ad4cf3 in clang::Preprocessor::HandleIdentifier(clang::Token&) () from /usr/local/clang-3.3/lib/libclang.so
Full stack trace can be found at
https://gist.github.com/jhanssen/5479586