[cfe-dev] libclang in c99-to-c89: crash detected during parsing
i-love-spam
i-love-spam at yandex.ru
Sun Apr 28 09:34:09 PDT 2013
I don't think there is anything wrong with the tool itself. I'm pretty sure, it's a problem of the libclang, or problem of ms headers that cause it to crash.
The problem happens on the first step before anything was ever done:
index = clang_createIndex(1, 1);
TU = clang_createTranslationUnitFromSourceFile(index, infile, argc, argv, 0, NULL);
clang_createTranslationUnitFromSourceFile generates that "libclang: crash detected during parsing".
If I use LLVM 3.2 release instead of current SVN, then everything works fine.
I tried to debug the crash and it crashes while parsing ms-style inline asm. Here's the backtrace of the crash: http://pastie.org/7733830
here's the piece of code that crashes it (inside clang\lib\Sema\SemaStmtAsm.cpp):
Sema::ActOnMSAsmStmt(...)
...
const llvm::Target *TheTarget(llvm::TargetRegistry::lookupTarget(TT, Error));
OwningPtr<llvm::MCAsmInfo> MAI(TheTarget->createMCAsmInfo(TT));
crash because TheTarget is NULL.
Also, EE is set to this string at this point: "Unable to find target for this triple (no targets are registered)"
27.04.2013, 08:53, "Reid Kleckner" <rnk at google.com>:
> I've hit similar issues with this tool where the tool made bad assumptions about AST structure. You should take it up with Ronald and the ffmpeg people using c99conv.
>
> Sent from phone
> On Apr 26, 2013 12:14 PM, "i-love-spam" <i-love-spam at yandex.ru> wrote:
>> There is a small app that translated c99 src code to c89 (mainly to be able to compile some projects written in c99 with MS compiler).
>> https://github.com/libav/c99-to-c89
>>
>> I've built clang (with vs2008) and used that project multiple times, however, with latest builds of clang it does not work anymore.
>> Some files suddenly now produce error like this one:
>>
>> libclang: crash detected during parsing: {
>> 'source_filename' : 'check_closesocket.i'
>> 'command_line_args' : [],
>> 'unsaved_files' : [],
>> 'options' : 1,
>> }
>>
>> The source code of the c99conv is here: https://github.com/libav/c99-to-c89/blob/master/convert.c
>> If I replace libclang.dll with the one from 21st October 2012 svn of clang/llvm then everything works fine.
>>
>> here's the test file check_closesocket.c:
>>
>> #include <winsock2.h>
>> long check_closesocket(void) { return (long) closesocket; }
>> int main(void) { return 0; }
>>
>> First, I generate preprocessed file (from vs2008 or 2010 command prompt):
>> cl -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -Dsnprintf=avpriv_snprintf -D_snprintf=avpriv_snprintf -Dvsnprintf=avpriv_vsnprintf -nologo -D_USE_MATH_DEFINES -Dinline=__inline -FIstdlib.h -Dstrtoll=_strtoi64 -Oy -P check_closesocket.c
>>
>> output is saved to check_closesocket.i
>>
>> Then, if I run this command:
>> c99conv check_closesocket.i check_closesocket.o_converted.c
>> or
>> c99conv -ms check_closesocket.i check_closesocket.o_converted.c
>>
>> I get the libclang: crash detected during parsing
>>
>> any idea where parser became unable to parse ms headers?
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list