I also tried to analyze error stacktraces, maybe this would help:
For the first error:
#0 0x00007fe111a7c93c in clang::Type::isDependentType (this=<optimized out>) at /CppSharp/build/llvm/llvm-6eb36a-linux-x64-gcc-9-Release/clang/include/clang/AST/Type.h:2366
#1 CppSharp::CppParser::Parser::WalkType (this=0x55555570a250, QualType=..., TL=<optimized out>, DesugarType=<optimized out>) at /CppSharp/src/CppParser/Parser.cpp:2933
#2 0x00007fe111a7e233 in CppSharp::CppParser::Parser::GetQualifiedType (this=0x55555570a250, qual=..., TL=0x7fffffffaa90) at /CppSharp/src/CppParser/Parser.cpp:595
#3 0x00007fe111a82bf1 in CppSharp::CppParser::Parser::WalkVariable (this=0x55555570a250, VD=0x7fe11da44108, Var=0x5555561d7480) at /CppSharp/src/CppParser/Parser.cpp:3512
#4 0x00007fe111a82db5 in CppSharp::CppParser::Parser::WalkVariable (this=0x55555570a250, VD=0x7fe11da44108) at /CppSharp/src/CppParser/Parser.cpp:3532
#5 0x00007fe111a79e93 in CppSharp::CppParser::Parser::WalkDeclaration (this=0x55555570a250, D=0x7fe11da44108) at /CppSharp/src/CppParser/Parser.cpp:4206
#6 0x00007fe111a83af5 in CppSharp::CppParser::Parser::WalkDeclarationDef (this=this@entry=0x55555570a250, D=D@entry=0x7fe11da44108) at /CppSharp/src/CppParser/Parser.cpp:3994
#7 0x00007fe111a83f3f in CppSharp::CppParser::Parser::WalkAST (this=0x55555570a250, TU=TU@entry=0x55555577a0f8) at /CppSharp/src/CppParser/Parser.cpp:3493
#8 0x00007fe111a8403c in SemaConsumer::HandleTranslationUnit (this=0x5555557285b0, Ctx=...) at /CppSharp/src/CppParser/Parser.cpp:4455
#9 0x00007fe112549bd9 in clang::ParseAST(clang::Sema&, bool, bool) () from /CppSharp/bin/Release_x64/libCppSharp.CppParser.so
#10 0x00007fe111a7275b in CppSharp::CppParser::Parser::Parse (this=0x55555570a250, SourceFiles=...) at /usr/include/c++/9/bits/unique_ptr.h:154
#11 0x00007fe111a7360a in CppSharp::CppParser::ClangParser::ParseHeader (Opts=0x55555559a8c0) at /CppSharp/src/CppParser/Parser.cpp:4791
#12 0x00007fff790e5a37 in ?? ()
#13 0x66612f74756f2d70 in ?? ()
#14 0x000000000a6ea19e in ?? ()
#15 0x00007ffff792b378 in ?? () from /usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.3/libcoreclr.so
#16 0xffffffffffffffff in ?? ()
#17 0x00007fff7a3a6b48 in ?? ()
#18 0x00007fff7a3a6b48 in ?? ()
#19 0x00007fffffffafe0 in ?? ()
#20 0x00007fff790e5a37 in ?? ()
#21 0x00007fffffffb0a0 in ?? ()
#22 0x632f72656b726f77 in ?? ()
#23 0x00007fff7a3a6b48 in ?? ()
#24 0x00005555555daa70 in ?? ()
#25 0x66612f74756f2d70 in ?? ()
#26 0x00007fe111a732e0 in ?? () at /CppSharp/src/CppParser/Parser.cpp:4849 from /CppSharp/bin/Release_x64/libCppSharp.CppParser.so
#27 0x00007fffffffae68 in ?? ()
#28 0x0000000000000000 in ?? ()
For the second error:
#0 CppSharp::CppParser::Parser::WalkVariable (this=0x55555570af50, VD=0x5555566c4888, Var=0x555556ab5d60) at /CppSharp/src/CppParser/Parser.cpp:3508
#1 0x00007fe111a82db5 in CppSharp::CppParser::Parser::WalkVariable (this=0x55555570af50, VD=0x5555566c4888) at /CppSharp/src/CppParser/Parser.cpp:3532
#2 0x00007fe111a79e93 in CppSharp::CppParser::Parser::WalkDeclaration (this=0x55555570af50, D=0x5555566c4888) at /CppSharp/src/CppParser/Parser.cpp:4206
#3 0x00007fe111a83af5 in CppSharp::CppParser::Parser::WalkDeclarationDef (this=this@entry=0x55555570af50, D=D@entry=0x5555566c4888) at /CppSharp/src/CppParser/Parser.cpp:3994
#4 0x00007fe111a83f3f in CppSharp::CppParser::Parser::WalkAST (this=0x55555570af50, TU=TU@entry=0x555555779e98) at /CppSharp/src/CppParser/Parser.cpp:3493
#5 0x00007fe111a8403c in SemaConsumer::HandleTranslationUnit (this=0x555555728350, Ctx=...) at /CppSharp/src/CppParser/Parser.cpp:4455
#6 0x00007fe112549bd9 in clang::ParseAST(clang::Sema&, bool, bool) () from /CppSharp/bin/Release_x64/libCppSharp.CppParser.so
#7 0x00007fe111a7275b in CppSharp::CppParser::Parser::Parse (this=0x55555570af50, SourceFiles=...) at /usr/include/c++/9/bits/unique_ptr.h:154
#8 0x00007fe111a7360a in CppSharp::CppParser::ClangParser::ParseHeader (Opts=0x55555559a6e0) at /CppSharp/src/CppParser/Parser.cpp:4791
#9 0x00007fff790e5a37 in ?? ()
#10 0x66612f74756f2d70 in ?? ()
#11 0x000000000a6ea1ea in ?? ()
#12 0x00007ffff792b378 in ?? () from /usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.3/libcoreclr.so
#13 0xffffffffffffffff in ?? ()
#14 0x00007fff7a3a6b48 in ?? ()
#15 0x00007fff7a3a6b48 in ?? ()
#16 0x00007fffffffafe0 in ?? ()
#17 0x00007fff790e5a37 in ?? ()
#18 0x00007fffffffb0a0 in ?? ()
#19 0x6172632f72656b72 in ?? ()
#20 0x00007fff7a3a6b48 in ?? ()
#21 0x00005555555daa70 in ?? ()
#22 0x66612f74756f2d70 in ?? ()
#23 0x00007fe111a732e0 in ?? () at /CppSharp/src/CppParser/Parser.cpp:4849 from /CppSharp/bin/Release_x64/libCppSharp.CppParser.so
#24 0x00007fffffffae68 in ?? ()
#25 0x0000000000000000 in ?? ()
I also found out that when seg2.txt input is compiled, it has such compilation warnings:
Hi! I've tried to fuzz CppSharp with sydr-fuzz (based on SharpFuzz core) and found some crashes that i don't know how to fix. Maybe my issue is related to https://github.com/mono/CppSharp/pull/1819.
I used Parser example to fuzz and found 2 different segmentation fault crashes.
Environment
How to reproduce these errors
Build docker container:
Run docker container:
Run on following input1 and input2:
Output:
For the first error:
For the second error:
I also tried to analyze error stacktraces, maybe this would help:
For the first error:
For the second error:
I also found out that when
seg2.txt
input is compiled, it has such compilation warnings:So maybe segfault emerges when non-UTF-8 symbols are inserted into input file.