[cfe-dev] clang 3.2 libclang: crash detected during reparsing

Argyrios Kyrtzidis akyrtzi at gmail.com
Thu Apr 4 15:45:20 PDT 2013


On Apr 4, 2013, at 12:14 AM, Oliver Giles <ogtifs at gmail.com> wrote:

> I just tried this again with the latest clang from svn. The original snippet works but the next lines in my original code are:
> 
> CXCursor cursor = clang_getTranslationUnitCursor(tu);
> CXSourceRange sr = clang_getCursorExtent(cursor);
> CXToken* tokens;
> unsigned numtokens;
> clang_tokenize(tu, sr, &tokens, &numtokens);
> CXCursor* cursors = new CXCursor[numtokens];
> clang_annotateTokens(tu, tokens, numtokens, cursors);
> 
> Appending even the first line of this (clang_getTranslationUnitCursor) to the example I gave earlier causes a segfault in the clang 3.3 library.

Fixed in r178800. FYI, it looks like the CXTranslationUnit object that you get is null, so there was a problem during parsing.

> 
> Oliver
> 
> On 2013-01-16 20:14, Argyrios Kyrtzidis wrote:
>> Fixed in r172632, thanks!
>> 
>> On Jan 15, 2013, at 9:36 PM, Oliver <ogtifs at gmail.com> wrote:
>> 
>>> Hi,
>>> Some example code for document editing I was using with clang 3.1 now segfaults on clang 3.2:
>>> 
>>> #include <clang-c/Index.h>
>>> #include <string.h>
>>> 
>>> char DOCUMENT[] = "int main() { return 0; }\n";
>>> 
>>> int main(int argc, char** argv) {
>>> 	const char* args;
>>> 	CXIndex ci = clang_createIndex(0,0);
>>> 	CXTranslationUnit tu =
>>> 			clang_parseTranslationUnit(ci, "main.cpp", &args,
>>> 			 0, NULL, 0, clang_defaultEditingTranslationUnitOptions());
>>> 	CXUnsavedFile file;
>>> 	file.Filename = "main.cpp";
>>> 	file.Contents = DOCUMENT;
>>> 	file.Length = strlen(DOCUMENT);
>>> 	clang_reparseTranslationUnit(tu, 1, &file, clang_defaultEditingTranslationUnitOptions());
>>> 	return 0;
>>> }
>>> 
>>> Output is:
>>> libclang: crash detected during reparsing
>>> Segmentation fault (core dumped)
>>> 
>>> Am I doing something perverted or is this a bug?
>>> 
>>> Oliver
>>> _______________________________________________
>>> cfe-dev mailing list
>>> cfe-dev at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130404/7365c9d8/attachment.html>


More information about the cfe-dev mailing list