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

genreflex crash in TMetaUtils::ReSubstTemplateArg with gcc12 headers #11259

Closed
1 task done
scott-snyder opened this issue Aug 26, 2022 · 5 comments
Closed
1 task done
Assignees
Labels
affects:master affects:6.26 bug experiment Affects an experiment / reported by its software & computimng experts in:Cling priority:critical
Milestone

Comments

@scott-snyder
Copy link
Collaborator

scott-snyder commented Aug 26, 2022

  • Checked for duplicates

hi -

We've been seing a crash in genreflex/rootcling in root-6.26.06-patches
when processing gcc12 headers. (See ATEAM-854.)

To reproduce:

sel.xml:

<lcgdict>
  <class pattern="*iterator<*pair<const*,const*"/>
</lcgdict>

x.h:

#include <string>
#include <map>
void foo (std::map<unsigned, std::string>& m, const std::string& s)
{
  m.emplace (0, s);
}

On lxplus7:

$ export LCGPROJECTPATH=/cvmfs/sft-nightlies.cern.ch/lcg/nightlies/dev4/Thu # Adjust if needed.
$ . $LCGPROJECTPATH/gcc/12.1.0/x86_64-centos7/setup.sh
$ . $LCGPROJECTPATH/ROOT/v6-26-00-patches/x86_64-centos7-gcc12-dbg/ROOT-env.sh 
$ genreflex x.h --selection_file=sel.xml -o x_gen.cxx
genreflex: /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-v6-26-00-patches/src/ROOT/v6-26-00-patches/interpreter/llvm/src/tools/clang/include/clang/AST/TemplateBase.h:257: clang::QualType clang::TemplateArgument::getAsType() const: Assertion `getKind() == Type && "Unexpected kind"' failed.

It also crashes in the opt build, just a bit further on.

Stack trace:

#4  0x00007ffff2f71cf3 in clang::TemplateArgument::getAsType (
    this=0x7fffef6df2e8)
    at /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-v6-26-00-patches/src/ROOT/v6-26-00-patches/interpreter/llvm/src/tools/clang/include/clang/AST/TemplateBase.h:257
#5  0x00007ffff2f85aeb in ROOT::TMetaUtils::ReSubstTemplateArg (input=..., 
    instance=0x7fffef6df2c0)
    at /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-v6-26-00-patches/src/ROOT/v6-26-00-patches/core/clingutils/src/TClingUtils.cxx:4768
#6  0x00007ffff2f85c07 in ROOT::TMetaUtils::ReSubstTemplateArg (input=..., 
    instance=0x7fffef6df2c0)
    at /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-v6-26-00-patches/src/ROOT/v6-26-00-patches/core/clingutils/src/TClingUtils.cxx:4791
#7  0x00007ffff32362a4 in TClingBaseClassInfo::InternalNext (
    this=0x7fffffff4430, onlyDirect=1)
    at /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-v6-26-00-patches/src/ROOT/v6-26-00-patches/core/metacling/src/TClingBaseClassInfo.cxx:341
#8  0x00007ffff323636e in TClingBaseClassInfo::Next (this=0x7fffffff4430, 
    onlyDirect=1)
    at /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-v6-26-00-patches/src/ROOT/v6-26-00-patches/core/metacling/src/TClingBaseClassInfo.cxx:350
#9  0x00007ffff323638d in TClingBaseClassInfo::Next (this=0x7fffffff4430)
    at /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-v6-26-00-patches/src/ROOT/v6-26-00-patches/core/metacling/src/TClingBaseClassInfo.cxx:355
#10 0x00007ffff30f8681 in TCling::CreateListOfBaseClasses (this=0x4b6670, 
    cl=0x32e8cc0)
    at /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-v6-26-00-patches/src/ROOT/v6-26-00-patches/core/metacling/src/TCling.cxx:4292
#11 0x00007ffff260dc29 in TClass::GetListOfBases (this=0x32e8cc0)
    at /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-v6-26-00-patches/src/ROOT/v6-26-00-patches/core/meta/src/TClass.cxx:3649
#12 0x00007ffff260a96e in TClass::GetBaseClass (this=0x32e8cc0, cl=0x235be20)
    at /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-v6-26-00-patches/src/ROOT/v6-26-00-patches/core/meta/src/TClass.cxx:2679
#13 0x00007ffff260a9f6 in TClass::GetBaseClass (this=0x2c3e4b0, cl=0x235be20)
    at /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-v6-26-00-patches/src/ROOT/v6-26-00-patches/core/meta/src/TClass.cxx:2688
#14 0x00007ffff2611f76 in TClass::InheritsFrom (this=0x2c3e4b0, cl=0x235be20)
    at /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-v6-26-00-patches/src/ROOT/v6-26-00-patches/core/meta/src/TClass.cxx:4891
#15 0x00007ffff26163d7 in TClass::Property (this=0x2c3e4b0)
    at /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-v6-26-00-patches/src/ROOT/v6-26-00-patches/core/meta/src/TClass.cxx:6097
#16 0x00007ffff261a27d in TClass::IsClassStructOrUnion (this=0x2c3e4b0)
    at /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-v6-26-00-patches/src/ROOT/v6-26-00-patches/core/meta/inc/TClass.h:352
#17 0x00007ffff260e309 in TClass::GetListOfDataMembers (this=0x2c3e4b0, 
    load=true)
    at /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-v6-26-00-patches/src/ROOT/v6-26-00-patches/core/meta/src/TClass.cxx:3759
#18 0x00007ffff7d132ac in CloseStreamerInfoROOTFile (writeEmptyRootPCM=false)
    at /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-v6-26-00-patches/src/ROOT/v6-26-00-patches/io/rootpcm/src/rootclingIO.cxx:162
#19 0x00007ffff305e2a7 in FinalizeStreamerInfoWriting (interp=..., 
    writeEmptyRootPCM=false)
    at /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-v6-26-00-patches/src/ROOT/v6-26-00-patches/core/dictgen/src/rootcling_impl.cxx:2632
#20 0x00007ffff305ecd8 in GenerateFullDict (dictStream=..., interp=..., 
    scan=..., ctorTypes=..., isSplit=false, isGenreflex=true, 
    writeEmptyRootPCM=false)
    at /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-v6-26-00-patches/src/ROOT/v6-26-00-patches/core/dictgen/src/rootcling_impl.cxx:2784
#21 0x00007ffff306ba57 in RootClingMain (argc=7, argv=0x4a4f10, 
    isGenreflex=true)
    at /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-v6-26-00-patches/src/ROOT/v6-26-00-patches/core/dictgen/src/rootcling_impl.cxx:4906
#22 0x00007ffff306f44b in genreflex::invokeRootCling (verbosity=..., 
    selectionFileName=..., targetLibName=..., multiDict=false, pcmsNames=..., 
    includes=..., preprocDefines=..., preprocUndefines=..., warnings=..., 
    rootmapFileName=..., rootmapLibName=..., interpreteronly=false, 
    doSplit=false, isCxxmodule=false, writeEmptyRootPCM=false, 
    selSyntaxOnly=false, noIncludePaths=false, noGlobalUsingStd=false, 
    headersNames=..., failOnWarnings=false, ofilename=...)
    at /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-v6-26-00-patches/src/ROOT/v6-26-00-patches/core/dictgen/src/rootcling_impl.cxx:5371
#23 0x00007ffff307131c in GenReflexMain (argc=3, argv=0x7fffffff8d40)
    at /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-v6-26-00-patches/src/ROOT/v6-26-00-patches/core/dictgen/src/rootcling_impl.cxx:6071
#24 0x00007ffff30717b3 in ROOT_rootcling_Driver (argc=5, argv=0x7fffffff8d38, 
    config=...)
    at /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-v6-26-00-patches/src/ROOT/v6-26-00-patches/core/dictgen/src/rootcling_impl.cxx:6148
#25 0x0000000000401269 in main (argc=5, argv=0x7fffffff8d38)
    at /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-v6-26-00-patches/src/ROOT/v6-26-00-patches/main/src/rootcling.cxx:43

The crash occurs here in TClingUtils.cxx:

        } else {
            return TST->getArg(index).getAsType();
        }

because the Kind of this argument is clang::TemplateArgument::Expression,
not Type.

This change fixes the crash for me:

diff --git a/core/clingutils/src/TClingUtils.cxx b/core/clingutils/src/TClingUtils.cxx
index 2373f0c..ee0cf7c 100644
--- a/core/clingutils/src/TClingUtils.cxx
+++ b/core/clingutils/src/TClingUtils.cxx
@@ -4765,7 +4765,8 @@ clang::QualType ROOT::TMetaUtils::ReSubstTemplateArg(clang::QualType input, cons
             // (See AddDefaultParameters).
             return input;
          } else {
-            return TST->getArg(index).getAsType();
+           if (TST->getArg(index).getKind() == clang::TemplateArgument::Type)
+             return TST->getArg(index).getAsType();
          }
       }
    }

This is a blocker for ATLAS testing with gcc12.

@elmsheus elmsheus added the experiment Affects an experiment / reported by its software & computimng experts label Aug 27, 2022
@Axel-Naumann Axel-Naumann added this to the 6.26/08 milestone Aug 30, 2022
@pcanal
Copy link
Member

pcanal commented Aug 31, 2022

I can reproduce the problem but still to assert if the proposed solution cover the intent.

In the meantime, a genuine question. What is the intent of:

<class pattern="*iterator<*pair<const*,const*"/>

i.e. maybe it is no longer necessary or can be fine tuned (eg. this request the dictionary for classes like "__and_<is_constructible<_Rb_tree_iterator<pair<const unsigned int,string> >,const _Rb_tree_iterator<pair<const unsigned int,string> >&>,is_constructible<bool,const bool&> >"

@Axel-Naumann Axel-Naumann removed their assignment Sep 1, 2022
pcanal added a commit to pcanal/root that referenced this issue Sep 1, 2022
This addresses the issue described in root-project#11259.  In particular it handles the case where the template parameter
is a value.  i.e. in the inner template of
```
__and_<is_constructible<_Rb_tree_iterator<pair<const unsigned int,string> >,const _Rb_tree_iterator<pair<const unsigned int,string> >&>,is_constructible<bool,const bool&> >
```
pcanal added a commit to pcanal/root that referenced this issue Sep 1, 2022
This addresses the issue described in root-project#11259.  In particular it handles the case where the template parameter
is a value.  i.e. in the inner template of
```
__and_<is_constructible<_Rb_tree_iterator<pair<const unsigned int,string> >,const _Rb_tree_iterator<pair<const unsigned int,string> >&>,is_constructible<bool,const bool&> >
```
pcanal added a commit that referenced this issue Sep 2, 2022
This addresses the issue described in #11259.  In particular it handles the case where the template parameter
is a value.  i.e. in the inner template of
```
__and_<is_constructible<_Rb_tree_iterator<pair<const unsigned int,string> >,const _Rb_tree_iterator<pair<const unsigned int,string> >&>,is_constructible<bool,const bool&> >
```
@pcanal
Copy link
Member

pcanal commented Sep 2, 2022

See #11302

@pcanal
Copy link
Member

pcanal commented Sep 2, 2022

Thanks for the thorough analysis.

pcanal added a commit to pcanal/root that referenced this issue Sep 2, 2022
This addresses the issue described in root-project#11259.  In particular it handles the case where the template parameter
is a value.  i.e. in the inner template of
```
__and_<is_constructible<_Rb_tree_iterator<pair<const unsigned int,string> >,const _Rb_tree_iterator<pair<const unsigned int,string> >&>,is_constructible<bool,const bool&> >
```
pcanal added a commit to pcanal/root that referenced this issue Sep 2, 2022
This addresses the issue described in root-project#11259.  In particular it handles the case where the template parameter
is a value.  i.e. in the inner template of
```
__and_<is_constructible<_Rb_tree_iterator<pair<const unsigned int,string> >,const _Rb_tree_iterator<pair<const unsigned int,string> >&>,is_constructible<bool,const bool&> >
```
pcanal added a commit that referenced this issue Sep 2, 2022
This addresses the issue described in #11259.  In particular it handles the case where the template parameter
is a value.  i.e. in the inner template of
```
__and_<is_constructible<_Rb_tree_iterator<pair<const unsigned int,string> >,const _Rb_tree_iterator<pair<const unsigned int,string> >&>,is_constructible<bool,const bool&> >
```
pcanal added a commit that referenced this issue Sep 2, 2022
This addresses the issue described in #11259.  In particular it handles the case where the template parameter
is a value.  i.e. in the inner template of
```
__and_<is_constructible<_Rb_tree_iterator<pair<const unsigned int,string> >,const _Rb_tree_iterator<pair<const unsigned int,string> >&>,is_constructible<bool,const bool&> >
```
@scott-snyder
Copy link
Collaborator Author

In the meantime, a genuine question. What is the intent of:

<class pattern="*iterator<*pair<const*,const*"/>

Thanks Philippe. Indeed, this pattern is something which had been in the selection for years, but when i double-checked, it was not in fact selecting anything useful. So we should be able to solve our immediate problem by just removing this.
Thanks!

pcanal added a commit that referenced this issue Sep 6, 2022
This addresses the issue described in #11259.  In particular it handles the case where the template parameter
is a value.  i.e. in the inner template of
```
__and_<is_constructible<_Rb_tree_iterator<pair<const unsigned int,string> >,const _Rb_tree_iterator<pair<const unsigned int,string> >&>,is_constructible<bool,const bool&> >
```
@pcanal
Copy link
Member

pcanal commented Sep 6, 2022

This is now fixed in the branch for v6.28/00 and v6.26/08

@pcanal pcanal closed this as completed Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects:master affects:6.26 bug experiment Affects an experiment / reported by its software & computimng experts in:Cling priority:critical
Projects
None yet
Development

No branches or pull requests

4 participants