hfinkel / llvm-project-cxxjit

Clang with JIT extensions
https://github.com/hfinkel/llvm-project-cxxjit/wiki
229 stars 23 forks source link

Segmentation fault with branch cxxjit-ni-9.0 #25

Open jpedrick opened 3 years ago

jpedrick commented 3 years ago

Version:

Target: x86_64-unknown-linux-gnu
Thread model: posix

I'm getting a segmentation fault with the following stacktrace:

#0  clang::QualType::getTypePtr (this=<synthetic pointer>) at /home/jpedrick/Development/llvm-project-cxxjit/clang/include/clang/AST/Type.h:6143
#1  clang::QualType::operator-> (this=<synthetic pointer>) at /home/jpedrick/Development/llvm-project-cxxjit/clang/include/clang/AST/Type.h:701
#2  (anonymous namespace)::CompilerData::getTemplateArgumentFromData (this=this@entry=0x12713790, Ty=Ty@entry=..., Values=Values@entry=0x7ffffff77760, Offset=Offset@entry=0, Size=Size@entry=32, TD=<optimized out>,
    Loc=..., Builder=...) at /home/jpedrick/Development/llvm-project-cxxjit/clang/lib/CodeGen/JIT.cpp:1078
#3  0x00007fffefc05797 in (anonymous namespace)::CompilerData::instantiateTemplate (this=this@entry=0x12713790, Values=Values@entry=0x7ffffff77760, Idx=<optimized out>, Idx@entry=2)
    at /home/jpedrick/Development/llvm-project-cxxjit/clang/lib/CodeGen/JIT.cpp:1292
#4  0x00007fffefc22459 in (anonymous namespace)::CompilerData::resolveFunction (this=this@entry=0x12713790, Values=Values@entry=0x7ffffff77760, Idx=Idx@entry=2, Errors=std::vector of length 0, capacity 0,
    Warnings=std::vector of length 0, capacity 0) at /home/jpedrick/Development/llvm-project-cxxjit/clang/lib/CodeGen/JIT.cpp:1412
#5  0x00007fffefc25359 in __clang_jit_i (CmdArgs=0xefa3a6, CmdArgsLen=3296, ASTBuffer=<optimized out>, ASTBufferSize=270817312, IRBuffer=0xd6ab55, IRBufferSize=1636432, LocalPtrs=0x11577a00, LocalPtrsCnt=1,
    LocalDbgPtrs=0x11577a10, LocalDbgPtrsCnt=534, DeviceData=0x0, DevCnt=0, Values=0x7ffffff77760, ValuesSize=64,
    InstKey=0xd5e421 "_ZN6sample24make_<omitted>__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE#_ZTSNSt7__cxx1112basic_stringIcSt11char_trait"..., Idx=2, DFTI=0x7ffffff777a8) at /home/jpedrick/Development/llvm-project-cxxjit/clang/lib/CodeGen/JIT.cpp:1926

<The rest is from proprietary code I'm not at liberty to share>

A snippet of how I'm using cxxjit with types/most logic omitted:

template <typename P1, typename P2>
struct ParametersT {
  using param1 = P1;
  using param2 = P1;
};

template <typename P1, typename P2 >
[[clang::for_dynamic_instantiation]] std::shared_ptr< ATemplateClassBase >
make_ATemplateClass_internal( int val ) {
    return std::make_shared< ATemplateClass< ParametersT<P1, P2> > >( val );
}

std::shared_ptr< ATemplateClassBase >
make_ATemplateClass( int val )
{
  auto f = __clang_dynamic_function_template_instantiation<make_ATemplateClass_internal>( std::tuple<A,B,C>, std::tuple<D,E,F> );
  return f( val  );
}