Skip to content

Incorrect name normalization for template with size_t template argument #18363

@pcanal

Description

@pcanal

Check duplicate issues.

  • Checked for duplicates

Description

This is issue is reported indirectly in cms-sw/cmssw#47697 where this bug lead to an unwanted and failing auto-parsing, leading to a crash as a consequence of the failed auto-parsing.

The root cause is that the name normalization of:

template <size_t I> struct Outer { template <size_t II> struct View {}; };
Outer<128>
Outer<128>::View<128>

is not consistently handled. During dictionary generation we end up with the following:

Outer<128>
Outer<128UL>::View<128>

Note the type suffix in 1 out of the 3 possibility ... when none is (currently) desired.

In the reported case this lead the TProtoClass for Outer<128>::View<128> to have the (normalized) name Outer<128UL>::View<128> while at run-time we look up Outer<128>::View<128> fail to find it in the rootpcm when using the normalized name interface and thus go through a phase of name normalization which (due to the same/similar failed lookup) leads to the need to load the class information in the interpreter (aka auto-parse its headers).

Reproducer

$ cat Objects.hxx 
#pragma once

namespace reco { 
template <size_t I, bool B> struct PFRecHitSoALayout {
  template <size_t II, bool B1, bool B2, bool B3> struct ViewTemplateFreeParams {};
  using View = ViewTemplateFreeParams<I, B, true, true>; 
}; 
using PFRecHitSoA = PFRecHitSoALayout<128UL,false>; // try with 128ul
}

static reco::PFRecHitSoA abc;
static reco::PFRecHitSoALayout<128UL,false> a2;
$ cat LinkDef.h 
#pragma link C++ class reco::PFRecHitSoA+;
#pragma link C++ class reco::PFRecHitSoA::View+;
$ cat Makefile 
all: libCmsSoa.so DataFormatsParticleFlowReco_x2r.cxx

DataFormatsParticleFlowReco_x2r.cxx:  Objects.hxx selection.xml
	rootcling --reflex -failOnWarnings -f -rml libCmsSoa.so -rmf libCmsSoa.rootmap  DataFormatsParticleFlowReco_x2r.cxx Objects.hxx selection.xml

libCmsSoa.so: DataFormatsParticleFlowReco_x2r.cxx
	g++ `root-config --cflags --libs` -o libCmsSoa.so -fPIC --shared DataFormatsParticleFlowReco_x2r.cxx

clean:
	rm -f libCmsSoa.so DataFormatsParticleFlowReco_x2r.cxx DataFormatsParticleFlowReco_x2r_rdict.pcm libCmsSoa.rootmap
$ root.exe -b -l DataFormatsParticleFlowReco_x2r_rdict.pcm -e 'TObjArray *arr = nullptr; arr = gFile->Get<TObjArray>("__ProtoClasses"); arr->ls()' -q

ROOT version

up to v6.34.08

Installation method

any

Operating system

any

Additional context

@makortel

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions