ROOT segfault upon reloading macro


ROOT Version: v6.10.08 & v6.14.04
Platform: Linux
Compiler: gcc-7.3


I’m not sure if this is an issue with ROOT6 or Cling, but I get a crash and stacktrace when, within macro, the another macro is loaded twice:

void foo() {
 gROOT->LoadMacro("SomeAnalysis.C");
 gROOT->LoadMacro("SomeAnalysis.C"); // if commented-out, runs fine
}

No execution of the macros is necessary, only calling those two lines. Calling .L SomeAnalysis.C twice in the interpreter also causes an error.
If the contents of SomeAnalysis.C is copied to another file, gROOT will load them ok:

void foo() {
 gROOT->LoadMacro("SomeAnalysis.C");
 // this works
 gROOT->LoadMacro("CopyOfSomeAnalysis.C");
}

(If the copy is a hard-link or symbolic-link, it will crash)

The greater context of this is the AliRoot/AliPhysics packages for ALICE physics analyses, so this is actually very difficult to reproduce without having that whole environment installed (I’ve tried), but I don’t think it’s specific to AliRoot.

The issue appears to be duplicated symbols when including a header with a template class and some inline free functions is in the “SomeAnalysis.C” macro. In addition, specialized templates (that has been typedef’d) are included in the LinkDef already.

I’ve tried many, many permutations of preprocessor-macro guards around the code like

#if !defined(__CLING__) || defined(__ROOTCLING__)

to avoid reloading the free-functions or redefining the class, but then I get errors like operator+(double) ... not defined.

Moving functions like operator+ into the class seems to work, but I cannot move them all.

The whole thing is rather silly, as it’s a vector class that should be replaced by TVector3, but hasn’t been, and I’m not about to change everybody’s code.

I should also say that LoadMacro is called by the code-runners in the grid system, so I don’t really have any options if I want to submit multiple analyses in the same job (besides copying the analysis macro, apparently).

There was an original error which actually might be more interesting, or provide a big hint; loading the macro would throw a lot of errors like:

E-TInterpreter::AutoParse: Error parsing payload code for class AliFemtoManager with content: ...`
/home/akubera/alice/sw/ubuntu1804_x86-64/AliPhysics/u6-pipi-1/include/AliFmThreeVectorD.h:21:34: error: typedef redefinition with different types ('AliFmThreeVector<...>' vs 'AliFmThreeVector<...>')
typedef AliFmThreeVector<double> AliFmThreeVectorD;
                                 ^
G__PWGCFfemtoscopy dictionary forward declarations' payload:114:34: note: previous definition is here
typedef AliFmThreeVector<double> AliFmThreeVectorD __attribute__((annotate("$clingAutoload$AliFmThreeVectorD.h")))  __attribute__((annotate("$clingAut...

Any help on this issue would be greatly appreciated.

link-to-stacktrace

Going back to my first error actually might be useful:

In file included from G__PWGCFfemtoscopy dictionary payload:16:
In file included from /cvmfs/alice.cern.ch/el6-x86_64/Packages/AliPhysics/vAN-20190309_ROOT6-1/include/AliAnalysisTaskFemto.h:46:
In file included from /cvmfs/alice.cern.ch/el6-x86_64/Packages/AliPhysics/vAN-20190309_ROOT6-1/include/AliFemtoEventReaderESDChain.h:11:
In file included from /cvmfs/alice.cern.ch/el6-x86_64/Packages/AliPhysics/vAN-20190309_ROOT6-1/include/AliFemtoV0.h:14:
In file included from /cvmfs/alice.cern.ch/el6-x86_64/Packages/AliPhysics/vAN-20190309_ROOT6-1/include/AliFemtoTypes.h:45:
In file included from /cvmfs/alice.cern.ch/el6-x86_64/Packages/AliPhysics/vAN-20190309_ROOT6-1/include/AliFemtoVector.h:35:
In file included from /cvmfs/alice.cern.ch/el6-x86_64/Packages/AliPhysics/vAN-20190309_ROOT6-1/include/AliFmThreeVectorD.h:18:
/cvmfs/alice.cern.ch/el6-x86_64/Packages/AliPhysics/vAN-20190309_ROOT6-1/include/AliFmThreeVector.h:812:1: error: redefinition of 'operator+'
operator+ (const AliFmThreeVector<T> &v1, const AliFmThreeVector<X> &v2)
^
/cvmfs/alice.cern.ch/el6-x86_64/Packages/AliPhysics/vAN-20190309_ROOT6-1/include/AliFmThreeVector.h:812:1: note: previous definition is here
operator+ (const AliFmThreeVector<T> &v1, const AliFmThreeVector<X> &v2)
^

Note the " previous definition is here" line is the same as the redefinition line. There are include-guards around the file.

The source code can be found here: {github} AliFmThreeVector.h (note it is not “my code” so don’t offer suggestions on how it could be cleaned/better organized - I certainly know.)

Macro unloading / reloading does not work in (is not supported by) ROOT 6 (as of 2019.03.10).

What do you mean by “does not work”?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.