# Root crashes after fitting/iterating on some histograms

**URL:** <https://root-forum.cern.ch/t/root-crashes-after-fitting-iterating-on-some-histograms/38224>\
**Category:** Newbie\
**Tags:** hist\
**Created:** [March 2, 2020, 7:49pm UTC](https://root-forum.cern.ch/t/root-crashes-after-fitting-iterating-on-some-histograms/38224 "2020-03-02T19:49:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevinlinxc](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/kevinlinxc/32/21030_2.png) [@kevinlinxc](https://root-forum.cern.ch/u/kevinlinxc)\
**Post date:** [March 2, 2020, 7:49pm UTC](https://root-forum.cern.ch/t/root-crashes-after-fitting-iterating-on-some-histograms/38224/1 "2020-03-02T19:49:21Z")

</div>

I have a directory of root files.  
I have a macro that is supposed to iterate over them, doing the following for each:  
Create a histogram, fit a gaussian function, integrate the fit function and print out the value.

When I run the macro, the first run goes smoothly but then immediately I get this error message and stacktrace: [https://pastebin.com/9JqPpbkp](https://pastebin.com/9JqPpbkp). I’ve checked and the fit should not be empty, so I’m thinking it’s a memory error? I tried naming each histogram something different (appending the file name) but that did not fix the error. I can share the macro if requested.

_ROOT Version:_ 6.18/04  
_Platform:_ Windows  
_Compiler:_ Not Provided

* * *

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [March 3, 2020, 7:53am UTC](https://root-forum.cern.ch/t/root-crashes-after-fitting-iterating-on-some-histograms/38224/2 "2020-03-03T07:53:02Z")

</div>

Could you post a running macro as reproducer?

---

<div class="post-metadata">

**Author:** ![kevinlinxc](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/kevinlinxc/32/21030_2.png) [@kevinlinxc](https://root-forum.cern.ch/u/kevinlinxc)\
**Post date:** [March 3, 2020, 12:37pm UTC](https://root-forum.cern.ch/t/root-crashes-after-fitting-iterating-on-some-histograms/38224/3 "2020-03-03T12:37:49Z")

</div>

I’m sorry, what does that mean?

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [March 3, 2020, 12:41pm UTC](https://root-forum.cern.ch/t/root-crashes-after-fitting-iterating-on-some-histograms/38224/4 "2020-03-03T12:41:17Z")

</div>

How can I reproduce the error?
