Randomly a segmentation fault for uninitialized TTree

On lxplus: gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
On the mac: MacOSX10.15.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.27)
The latter looks like a… liberal compiler! :laughing:

So, I solved all the instability problems of my code when running on my mac just solving a number of very subtle source of segmentation fault on lxplus. On mac now it works stably!
Not on lxplus for what follows.
I am using the code you find here
https://root.cern/doc/v610/NumericalMinimization_8C_source.html
This is a fragment:

   ROOT::Math::Minimizer* minimum =
       ROOT::Math::Factory::CreateMinimizer(minName, algoName);  
    // set tolerance , etc...
    minimum->SetMaxFunctionCalls(1000000); // for Minuit/Minuit2
    minimum->SetMaxIterations(10000);  // for GSL
    minimum->SetTolerance(0.001);
    minimum->SetPrintLevel(1);

On my mac it works fine; on lxplus it generates a segmentation fault at the SetMaxFunctionCalls
Indeed ROOT::Math::Factory::CreateMinimizer(minName, algoName) returns zero!!!
Any idea?

Ah! I have just found everything is OK on lxplus too, if I do not specify any minimizer, i.e. minuit or minuit2 etc.) and assume the default (which I am not able to find which indeed it is: great documentation, I will say!)
But again: why on my mac specifying “Minuit2” does work?

Check:

root-config --features | grep -i minuit2
root-config --has-minuit2
`

Yes, thanks you. It looks like one MUST leave the default, that is one must not specify any minimizer on lxplus.
Given that, now everything works fine.

You can try GSL based minimizers, if you have:

root-config --features | grep -i mathmore
root-config --has-mathmore

I had already tried giving “minuit2” (not “Minuit2” as I found in Lorenzo Moneta’s
ROOT: tutorials/fit/NumericalMinimization.C Source File) argument for the name, but I got segmentation fault despite the fact that “minuit2” is found by root-config --features.

By now I am satisfied having my program working both on my mac and on lxplus.
Bye,
Ignazio

The “minimizer’s name” is case sensitive (i.e., you must use “Minuit2”).

@Axel If “root-config --has-minuit2” returns “yes” but “Minuit2” is not working, then I think it is a bug (specific to the default ROOT installation on lxplus?).

BTW. The default minimizer (when the “minimizer’s name” is empty) is the old “Minuit”.

Not “minuit2” nor “Minuit2” does work on lxplus, but “” (empty string) does.
“Minuit2” works on my mac.

I have just done one check more: I confirm that not “minuit2” nor “Minuit2” does work on lxplus, but “” (empty string) does.
“Minuit2” works on my mac.

Just to make sure … in your application, do you create a “TApplication” first (in your “main”)?

Yes, it does: it’s the first call in main.
My username is “lazi”. If you like, you find the whole code in my home, ANALISI subdirectory.

Post the full “stack trace” from lxplus and the output of “root-config --version --prefix --exec-prefix” (maybe that’s something people know about).

gdb.printing.register_pretty_printer(gdb.current_objfile(),
gdb.printing.register_pretty_printer(gdb.current_objfile(),
# #0 0x00007faf2bb6446c in waitpid () from /lib64/libc.so.6
#1 0x00007faf2bae1f62 in do_system () from /lib64/libc.so.6
#2 0x00007faf304ff58c in TUnixSystem::StackTrace() () from /usr/lib64/root/libCore.so.6.22
#3 0x00007faf3050201a in TUnixSystem::DispatchSignals(ESignals) () from /usr/lib64/root/libCore.so.6.22
#4
#5 0x0000000000463862 in ROOT::Math::MinimizerOptions::SetMaxFunctionCalls(unsigned int) ()
#6 0x00000000004638ec in ROOT::Math::Minimizer::SetMaxFunctionCalls(unsigned int) ()
#7 0x0000000000462bb4 in FitHist2Hist::_fit(double*, double*, char const*, char const*, int) ()
#8 0x0000000000462ffa in FitHist2Hist::go(double) ()
#9 0x0000000000447e14 in Analisi::look_for_gamma(std::map<std::string, TH1F*, std::lessstd::string, std::allocator<std::pair<std::string const, TH1F*> > >&) ()
#10 0x000000000044687c in Analisi::fillHistograms(std::vector<std::string, std::allocatorstd::string >) ()
#11 0x000000000043857a in main ()

Anyway the point is what I already said:
in

    ROOT::Math::Minimizer* minimum =
       ROOT::Math::Factory::CreateMinimizer(minName, algoName);

ROOT::Math::Factory::CreateMinimizer(minName, algoName) 

returns zero, whence the segmentation fault when doing like

minimum->SetMaxFunctionCalls(1000000);

I gave

minName = std::string("Minuit2"); algoName = std::string("");

What happens if you try: minName = std::string("Minuit");

With std::string(“Minuit2”) it doesn’t work as well.

I just wrote to Lorenzo Moneta who is the expert in the subject.

We need @moneta here!

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