Change in Minuit2 behaviour from 6.20.00 onwards

I’ve noticed recently that some of my fits are starting to crash with the following error,

…/root-6.22.00/math/minuit2/src/VariableMetricBuilder.cxx:272: ROOT::Minuit2::FunctionMinimum ROOT::Minuit2::VariableMetricBuilder::Minimum(const ROOT::Minuit2::MnFcn&, const ROOT::Minuit2::GradientCalculator&, const ROOT::Minuit2::MinimumSeed&, std::vectorROOT::Minuit2::MinimumState&, unsigned int, double) const: Assertion `s0.IsValid()’ failed.
Aborted (core dumped)

which doesn’t happen with 6.18.04 and earlier on the same code. Here’s a minimal example reproducing the problem that will finish with 6.18.04 but crash with 6.20.00 onwards,

#include "Minuit2/FCNBase.h"
#include "Minuit2/FunctionMinimum.h"
#include "Minuit2/MnMigrad.h"
#include "Minuit2/MnPrint.h"
#include "Minuit2/MnUserParameters.h"

class Fcn : public ROOT::Minuit2::FCNBase
  virtual double operator()( const std::vector<double>& par ) const
  { return 1.0; }

  virtual double Up() const
  { return 1.0; }

int main()
  ROOT::Minuit2::MnUserParameters mn_param;
  mn_param.Add("par1", 0.0, 0.001);

  Fcn fcn;
  ROOT::Minuit2::MnMigrad migrad(fcn, mn_param, 2);
  ROOT::Minuit2::FunctionMinimum min = migrad();
  std::cout << min << std::endl;

  return 0;

I wasn’t able to find any information in recent release notes concerning changes to Minuit2 so I was wondering if anyone knew what happened and if this new behaviour should be expected from now on?

_ROOT Version: 6.20.00 and above
Platform: Linux
Compiler: gcc9

Thanks for reporting the issue. @moneta will most probably take a look

There has been no change, you are probably using a debug build (containing assert) and a non debug build. In the first case , an assert is triggered since the initial state is invalid due to an invalid initial Hessian matrix. In that case happens because your function has zero second derivative.

Probably this assert can be removed and let anyway Minuit2 failing


Hi Lorenzo, thanks very much for your reply.

I’m building both versions of root from source with the same cmake command,

cmake …/root-6.xx.yy/ -DCMAKE_INSTALL_PREFIX=/opt/root -DCMAKE_BUILD_TYPE=Optimized -DCMAKE_CXX_STANDARD=17 -Dgminimal=ON -Dminuit2=ON -Dmathmore=ON

Is there an additional flag that should be set in order not to build a debug version?

-DCMAKE_BUILD_TYPE=Optimized should be -DCMAKE_BUILD_TYPE=Release (which is also the default). I am not sure whether using “Optimized” happens to add debug symbols.


Hi Enrico, that was it, thanks. I recompiled ROOT by removing that flag and now everything has returned to normal. Should something be done about the Optimized flag adding debug symbols, or was this flag intended more for developers rather than being for general use? I should probably report this downstream to Fedora as well as their rpm builds also suffer the crash.

Where did you find that Optimized build mode?

I should probably report this downstream to Fedora as well as their rpm builds also suffer the crash.

It’s totally ok for builds to have debug symbols, in general.

@moneta, how should the script be changed so that it does not trigger the assert?

I will anyway remove this assert() to avoid such problems in the future

The way I came to include the Optimized build mode was from the INSTALL file bundled with ROOT in the README directory. Section 6 pointed me to this webpage,

where I found CMAKE_BUILD_TYPE under the “Relevant CMake variables” heading. I guess my thinking was that Optimized should be the best option for fastest performance.

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