Roofit multivariable integration "create integral"

Is there a problem in integrating a multivariable variable function by:

RooAbsReal* intPdf0 = function.createIntegral(RooArgSet( r ), “R0”);
RooAbsReal* intPdf1 = intPdf0->createIntegral(RooArgSet(theta),“R0”);
RooAbsReal* intPdf2 = intPdf1->createIntegral(RooArgSet(psi));

instead of

RooAbsReal* intPdf0 = function.createIntegral(RooArgSet(r, theta, psi), “R0”);


It is faster when I do it in the first way,
but I get the following error: “free(): invalid next size (fast)”, so I wonder if there is something wrong with the first method.

Since I am integrating 8 variables, the second method seems unreasonable because the code runs for hours and doesn’t give me the answer. I already changed RooFit::Precision()…

Hope you can give me some light!

Hi @naikal_mc,

I guess an integration like in example 1 could work. I would need an example to see what’s going on. Could you attach a debugger to see where the problem occurs?

Dear @StephanH,

here is the output of:

gdb --args root.exe -l -b multdim2.C+

GNU gdb (Ubuntu 8.1-0ubuntu3.1)
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
Find the GDB manual and other documentation resources online at:
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from root.exe...done.
(gdb) r
Starting program: /usr/local/root/bin/root.exe -l -b multdim2.C+
warning: the debug information found in "/lib64/" does not match "/lib64/" (CRC mismatch).

warning: File "/usr/local/root/lib/" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
To enable execution of this file add
	add-auto-load-safe-path /usr/local/root/lib/
line to your configuration file "/home/maria/.gdbinit".
To completely disable this security protection add
	set auto-load safe-path /
line to your configuration file "/home/maria/.gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual.  E.g., run from the shell:
	info "(gdb)Auto-loading safe path"
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/".
root [0] 
Processing multdim2.C+...
Info in <TUnixSystem::ACLiC>: creating shared library /home/maria/Downloads/./
warning: File "/usr/local/root/lib/" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".

RooFit v3.60 -- Developed by Wouter Verkerke and David Kirkby 
                Copyright (C) 2000-2013 NIKHEF, University of California & Stanford University
                All rights reserved, please read

[#1] INFO:NumericIntegration -- RooRealIntegral::init(integ_Int[c,eta,l,lp,mass,phi,psi,theta]) using numeric integrator RooAdaptiveIntegratorND to calculate Int(theta,psi,l,phi,eta,mass,c,lp)
[#1] INFO:NumericIntegration -- RooRealIntegral::init(integ_Int[c,eta,l,lp,mass,phi,psi,theta]) evaluation requires 8-D numeric integration step. Evaluation may be slow, sufficient numeric precision for fitting & minimization is not guaranteed
free(): invalid next size (fast)

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.

Hey @naikal_mc,

very nice! If you now typed bt (=backtrace), gdb would print where the program stopped.


here it is :sweat_smile:

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff6b8b801 in __GI_abort () at abort.c:79
#2  0x00007ffff6bd4897 in __libc_message (action=action@entry=do_abort, 
    fmt=fmt@entry=0x7ffff6d01b9a "%s\n") at ../sysdeps/posix/libc_fatal.c:181
#3  0x00007ffff6bdb90a in malloc_printerr (
    str=str@entry=0x7ffff6d03800 "free(): invalid next size (fast)")
    at malloc.c:5350
#4  0x00007ffff6be2f60 in _int_free (have_lock=0, p=0x55555767d890, 
    av=0x7ffff6f36c40 <main_arena>) at malloc.c:4213
#5  __GI___libc_free (mem=0x55555767d8a0) at malloc.c:3124
#6  0x00007fffe8a52c4c in ROOT::v5::TFormula::ClearFormula (
    at /usr/local/root-6.18.04/hist/hist/src/TFormula_v5.cxx:2234
#7  0x00007fffe8a52ddf in ROOT::v5::TFormula::~TFormula (this=0x55555766c620, 
    __in_chrg=<optimized out>)
    at /usr/local/root-6.18.04/hist/hist/src/TFormula_v5.cxx:319
#8  0x00007fffe9d56579 in RooFormula::~RooFormula (this=0x55555766c620, 
    __in_chrg=<optimized out>)
    at /usr/local/root-6.18.04/roofit/roofitcore/src/RooFormula.cxx:135
#9  0x00007fffe9d58b0e in RooFormulaVar::~RooFormulaVar (this=0x7fffffff85e0, 
    __in_chrg=<optimized out>)
    at /usr/local/root-6.18.04/roofit/roofitcore/src/RooFormulaVar.cxx:106
#10 0x00007fffe62aa5c2 in multdim2() ()
---Type <return> to continue, or q <return> to quit---return
   from /home/maria/Downloads/
#11 0x00007ffff7fc006a in ?? ()
#12 0x0000555555845120 in ?? ()
#13 0x00000001f7fc0000 in ?? ()
#14 0x00007ffff20c7c40 in ?? () from /usr/local/root/lib/
#15 0x00007fffffffa5f0 in ?? ()
#16 0x00007ffff7fc0000 in ?? ()
#17 0x00007ffff20a1230 in cling::IncrementalExecutor::executeWrapper(llvm::StringRef, cling::Value*) const () from /usr/local/root/lib/
#18 0x00007ffff2034007 in cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) () from /usr/local/root/lib/
#19 0x00007ffff203566f in cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) ()
   from /usr/local/root/lib/
#20 0x00007ffff2035917 in cling::Interpreter::process(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::Value*, cling::Transaction**, bool) () from /usr/local/root/lib/
#21 0x00007ffff20f88bd in cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) ()
   from /usr/local/root/lib/
#22 0x00007ffff1fb481e in HandleInterpreterException (
    metaProcessor=0x5555559b7890, input_line=<optimized out>, 
---Type <return> to continue, or q <return> to quit---return
    compRes=@0x7fffffffa5dc: cling::Interpreter::kSuccess, 
    at /usr/local/root-6.18.04/core/metacling/src/TCling.cxx:2152
#23 0x00007ffff1fc8f9f in TCling::ProcessLine (this=0x5555557ef820, 
    line=<optimized out>, error=0x7fffffffb75c)
    at /usr/local/root-6.18.04/core/metacling/src/TCling.cxx:2269
#24 0x00007ffff1fbd6c7 in TCling::ProcessLineSynch (this=0x5555557ef820, 
    line=0x5555557f7cc0 ".X  /home/maria/Downloads/./multdim2.C+", 
    at /usr/local/root-6.18.04/core/metacling/src/TCling.cxx:3176
#25 0x00007ffff76ec908 in TApplication::ExecuteFile (file=<optimized out>, 
    error=0x7fffffffb75c, keep=<optimized out>)
    at /usr/local/root-6.18.04/core/base/src/TApplication.cxx:1162
#26 0x00007ffff76ec0ac in TApplication::ProcessLine (this=0x5555557dab30, 
    line=<optimized out>, sync=<optimized out>, err=0x7fffffffb75c)
    at /usr/local/root-6.18.04/core/base/src/TApplication.cxx:1007
#27 0x00007ffff7bbb8f2 in TRint::ProcessLineNr (
    filestem=filestem@entry=0x7ffff7bcdbaf "ROOT_cli_", 
    line=line@entry=0x7fffffffb760 ".x multdim2.C+", 
    at /usr/local/root-6.18.04/core/rint/src/TRint.cxx:761
#28 0x00007ffff7bbd1e9 in TRint::Run (this=0x5555557dab30, 
---Type <return> to continue, or q <return> to quit---return
    retrn=<optimized out>)
    at /usr/local/root-6.18.04/core/rint/src/TRint.cxx:421
#29 0x0000555555554a0c in main (argc=<optimized out>, argv=0x7fffffffd8e8)
    at /usr/local/root-6.18.04/main/src/rmain.cxx:30

The stack trace indicates that it’s a problem with a TFormulav5. It’s a known problem, and has been fixed in the development version of ROOT. Seeing that, I doubt that it’s connected to the integral.

You could try the nightly build from to confirm that this is indeed the problem.

1 Like

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