Memory error when using RooFit in ROOT macro


I’m experiencing an issue with a ROOT macro where I’m using RooFit for fitting invariant mass. During the execution of the macro, the program crashes and I receive the following error message:

root.exe(69313,0x1e1d4a500) malloc: Incorrect checksum for freed object 0x13726c200: probably modified after being freed.
Corrupt value: 0x13726c210
root.exe(69313,0x1e1d4a500) malloc: *** set a breakpoint in malloc_error_break to debug

I have been getting this error for quite sometime after I re-run the fitting macro several times (in hopes, of getting the best possible fit). To debug this, I tried using LLDB and set a breakpoint on malloc_error_break, as suggested by the error message. However, during the execution of my macro, this breakpoint was not hit. I pasted my macro below.
Dzeroes_MassFit.C (13.5 KB)

I’m running ROOT 6.24/08 on macOS Ventura 13.00, and I use Xcode.

I would appreciate any suggestions on what might be causing this issue and how I could resolve it.

Thanks in advance for your help!


Dear @joarias ,

A first useful exercise you may do is removing every new and delete statement from your code, substituing them with std::unique_ptr whenever you create the corresponding variable. Do this first and see if the problem persists.

@jonas FYI


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