Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault when calling InstantiateTemplate #36

Open
vgvassilev opened this issue Mar 11, 2023 · 2 comments
Open

Segmentation fault when calling InstantiateTemplate #36

vgvassilev opened this issue Mar 11, 2023 · 2 comments
Assignees
Labels
cppyy Affects python bindings with cppyy

Comments

@vgvassilev
Copy link
Contributor

vgvassilev commented Mar 11, 2023

We instantiate a template named T2 from test test_advancedcpp.py::test04_template_types with a vector of template arguments of 1 element which is a nullptr.

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff7dd9859 in __GI_abort () at abort.c:79
#2  0x00007ffff7dd9729 in __assert_fail_base (fmt=0x7ffff7f6f588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=0x7fffef055768 "!isNull() && \"Cannot retrieve a NULL type pointer\"", 
    file=0x7fffef055700 "/home/vvassilev/workspace/builds/scratch/cling-build/cling-src/tools/clang/include/clang/AST/Type.h", line=684, function=<optimized out>)
    at assert.c:92
#3  0x00007ffff7deaf36 in __GI___assert_fail (assertion=0x7fffef055768 "!isNull() && \"Cannot retrieve a NULL type pointer\"", 
    file=0x7fffef055700 "/home/vvassilev/workspace/builds/scratch/cling-build/cling-src/tools/clang/include/clang/AST/Type.h", line=684, 
    function=0x7fffef0556b0 "const clang::ExtQualsTypeCommonBase* clang::QualType::getCommonPtr() const") at assert.c:101
#4  0x00007fffe960ab66 in clang::QualType::getCommonPtr (this=0x7fffffff6e50)
    at /home/vvassilev/workspace/builds/scratch/cling-build/cling-src/tools/clang/include/clang/AST/Type.h:684
#5  0x00007fffe960c108 in clang::QualType::getTypePtr (this=0x7fffffff6e50)
    at /home/vvassilev/workspace/builds/scratch/cling-build/cling-src/tools/clang/include/clang/AST/Type.h:6430
#6  0x00007fffe960acde in clang::QualType::operator-> (this=0x7fffffff6e50)
    at /home/vvassilev/workspace/builds/scratch/cling-build/cling-src/tools/clang/include/clang/AST/Type.h:726
#7  0x00007fffe9611fc0 in clang::TypeLoc::getTypeLocClass (this=0x7fffffff6e70)
    at /home/vvassilev/workspace/builds/scratch/cling-build/cling-src/tools/clang/include/clang/AST/TypeLoc.h:117
#8  0x00007fffeb6949d7 in clang::TypeLoc::initializeImpl (Context=..., TL=..., Loc=...)
    at /home/vvassilev/workspace/builds/scratch/cling-build/cling-src/tools/clang/lib/AST/TypeLoc.cpp:134
#9  0x00007fffeae3eb39 in clang::TypeLoc::initialize (this=0x7fffffff6f20, Context=..., Loc=...)
    at /home/vvassilev/workspace/builds/scratch/cling-build/cling-src/tools/clang/include/clang/AST/TypeLoc.h:197
#10 0x00007fffeb043652 in clang::ASTContext::getTrivialTypeSourceInfo (this=0xfb83b0, T=..., L=...)
    at /home/vvassilev/workspace/builds/scratch/cling-build/cling-src/tools/clang/lib/AST/ASTContext.cpp:2908
#11 0x00007fffe5dfd887 in InterOp::InstantiateTemplate (ClassDecl=0x2ef63f8, TemplateArgs=..., S=...)
    at /home/vvassilev/workspace/builds/scratch/cppyy/InterOp/lib/Interpreter/InterOp.cpp:2105
#12 0x00007fffe5dfda41 in InterOp::InstantiateClassTemplate (interp=0xbe1e90, tmpl=0x2ef63f8, types=0x3005070, type_size=1)
    at /home/vvassilev/workspace/builds/scratch/cppyy/InterOp/lib/Interpreter/InterOp.cpp:2125
#13 0x00007fffe5df2351 in Cppyy::InstantiateTemplateClass (tmpl=0x2ef63f8, types=0x3005070, types_size=1)
    at /home/vvassilev/workspace/builds/scratch/cppyy/cppyy-backend/src/clingwrapper.cxx:1888
#14 0x00007fffe5955323 in (anonymous namespace)::MakeCppTemplateClass (args=0x7fffe54d5ec8)
    at /home/vvassilev/workspace/builds/scratch/cppyy/CPyCppyy/src/CPyCppyyModule.cxx:438
@vgvassilev vgvassilev changed the title Segmentation fault when calling Segmentation fault when calling InstantiateTemplate Mar 12, 2023
@aaronj0
Copy link
Collaborator

aaronj0 commented May 16, 2024

Minimal reproducable example:

template class T1<int>;
template class T2<T1<int> >;

and calling cppyy.gbl.T2

@aaronj0 aaronj0 self-assigned this May 16, 2024
@aaronj0 aaronj0 added the cppyy Affects python bindings with cppyy label May 16, 2024
@vgvassilev
Copy link
Contributor Author

Do you mean:

template <typename T> class T1{};
template class T1<int>;

template class T1<int>; is a class ClassTemplateSpecializationDecl you can't instantiate it. I guess the calling code needs to be protected for this case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cppyy Affects python bindings with cppyy
Projects
None yet
Development

No branches or pull requests

3 participants