[cfe-dev] Crash when accessing diagnostics

Matthias Kleine matthias_kleine at gmx.de
Thu Sep 12 09:55:54 PDT 2013


Hi all,

I encountered a crash when working with the libclang Python bindings, and need some help investigating it. I boiled down the crash to the following scenario:

----
index = clang.cindex.Index.create()
tu = index.parse("foo.cpp", ['-Weverything'], [('foo.cpp', 'class bar{void foo(){int x;};')])
list(tu.diagnostics)
----

Here's the relevant bit of the stack-trace
3   libclang.dylib                	0x000000010a937475 __assert_rtn + 53 (Signals.inc:379)
4   libclang.dylib                	0x000000010aedb03a applyRewrite(clang::edit::EditsReceiver&, llvm::StringRef, clang::edit::FileOffset, unsigned int, clang::SourceManager const&, clang::LangOptions const&) + 794 (EditedSource.cpp:321)
5   libclang.dylib                	0x000000010aedacb3 clang::edit::EditedSource::applyRewrites(clang::edit::EditsReceiver&) + 723 (SmallVector.h:87)
6   libclang.dylib                	0x000000010aa8ba95 clang::DiagnosticRenderer::emitDiagnostic(clang::SourceLocation, clang::DiagnosticsEngine::Level, llvm::StringRef, llvm::ArrayRef<clang::CharSourceRange>, llvm::ArrayRef<clang::FixItHint>, clang::SourceManager const*, llvm::PointerUnion<clang::Diagnostic const*, clang::StoredDiagnostic const*>) + 1045 (EditedSource.h:27)
7   libclang.dylib                	0x000000010aa8c7e3 clang::DiagnosticRenderer::emitStoredDiagnostic(clang::StoredDiagnostic&) + 195 (DiagnosticRenderer.cpp:191)
8   libclang.dylib                	0x000000010a7a0fcb clang::cxdiag::lazyCreateDiags(CXTranslationUnitImpl*, bool) + 411 (CIndexDiagnostic.cpp:198)
9   libclang.dylib                	0x000000010a7a106e clang_getNumDiagnostics + 30 (CIndexDiagnostic.cpp:213)


The crash will not happen without "-Weverything" nor without an unsaved / in memory file. I would be happy if someone could help me out with this.

Cheers,
Matthias



More information about the cfe-dev mailing list