Skip to content

Incorrect name normalization for template with size_t template argument #18363

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

Open
1 task done
pcanal opened this issue Apr 11, 2025 · 1 comment · May be fixed by #18373 or #18464
Open
1 task done

Incorrect name normalization for template with size_t template argument #18363

pcanal opened this issue Apr 11, 2025 · 1 comment · May be fixed by #18373 or #18464
Assignees
Labels
bug experiment Affects an experiment / reported by its software & computimng experts in:Cling in:Core Libraries in:Dictionaries priority:critical
Milestone

Comments

@pcanal
Copy link
Member

pcanal commented Apr 11, 2025

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

@pcanal pcanal added bug experiment Affects an experiment / reported by its software & computimng experts in:Cling in:Core Libraries in:Dictionaries priority:critical labels Apr 11, 2025
@pcanal pcanal added this to the 6.36.00 milestone Apr 11, 2025
@pcanal pcanal self-assigned this Apr 11, 2025
pcanal added a commit to pcanal/root that referenced this issue Apr 11, 2025
This solves problems caused by some code paths producing normalized name with unexpectedly
added type suffix after on integral non-type template parameters.

This fixes root-project#18363
pcanal added a commit to pcanal/root that referenced this issue Apr 12, 2025
This solves problems caused by some code paths producing normalized name with unexpectedly
added type suffix after on integral non-type template parameters.

This fixes root-project#18363
pcanal added a commit to pcanal/root that referenced this issue Apr 14, 2025
This solves problems caused by some code paths producing normalized name with unexpectedly
added type suffix after on integral non-type template parameters.

This fixes root-project#18363
@hahnjo hahnjo linked a pull request Apr 29, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug experiment Affects an experiment / reported by its software & computimng experts in:Cling in:Core Libraries in:Dictionaries priority:critical
Projects
None yet
2 participants
@pcanal and others