# pyROOT TMultiGraph Segmentation Fault

**URL:** <https://root-forum.cern.ch/t/pyroot-tmultigraph-segmentation-fault/26263>\
**Category:** ROOT\
**Tags:** python\
**Created:** [September 19, 2017, 5:30pm UTC](https://root-forum.cern.ch/t/pyroot-tmultigraph-segmentation-fault/26263 "2017-09-19T17:30:34Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![amadio](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/amadio/32/12562_2.png) [@amadio](https://root-forum.cern.ch/u/amadio)\
**Post date:** [September 28, 2017, 9:37am UTC](https://root-forum.cern.ch/t/pyroot-tmultigraph-segmentation-fault/26263/21 "2017-09-28T09:37:11Z")

</div>

@ksmith So, I guess this problem has been solved, right? Could you please mark @sbinet’s comment as solution? Thanks!

---

<div class="post-metadata">

**Author:** ![sbinet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/sbinet/32/13166_2.png) [@sbinet](https://root-forum.cern.ch/u/sbinet)\
**Post date:** [September 28, 2017, 10:41am UTC](https://root-forum.cern.ch/t/pyroot-tmultigraph-segmentation-fault/26263/22 "2017-09-28T10:41:13Z")

</div>

That’s not a solution.  
I just explained why in some setup you get garbled data.  
python shouldn’t let you get (silently!) garbled data.

in C++, when you don’t give the correct types to a function/method, the first line of defense (the compiler) will tell you, loudly.  
in python calling C++, the method dispatcher should tell you. right now, it doesn’t.

---

<div class="post-metadata">

**Author:** ![sbinet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/sbinet/32/13166_2.png) [@sbinet](https://root-forum.cern.ch/u/sbinet)\
**Post date:** [September 28, 2017, 10:42am UTC](https://root-forum.cern.ch/t/pyroot-tmultigraph-segmentation-fault/26263/23 "2017-09-28T10:42:37Z")

</div>

also, AFAIK, the original segfault still happens when the snippet of code is executed inside a function.  
that’s another bug 🙂

---

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [September 28, 2017, 2:33pm UTC](https://root-forum.cern.ch/t/pyroot-tmultigraph-segmentation-fault/26263/24 "2017-09-28T14:33:20Z")

</div>

> [@amadio](#):
>
> @ksmith So, I guess this problem has been solved, right? Could you please mark @sbinet’s comment as solution? Thanks!

I agree with @sbinet although he has proposed a possible avoidance of one issue, I would not call it solved. (He has clarified the cause nicely though it seems.) In addition, the original issue hasn’t been resolved although @Graipher’s suggestion to not use a method would be another work around.

---

<div class="post-metadata">

**Author:** ![amadio](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/amadio/32/12562_2.png) [@amadio](https://root-forum.cern.ch/u/amadio)\
**Post date:** [October 3, 2017, 1:49pm UTC](https://root-forum.cern.ch/t/pyroot-tmultigraph-segmentation-fault/26263/25 "2017-10-03T13:49:01Z")

</div>

Dear @ksmith,

Apologies for the delay. I discussed the matter with other members of the team and created a JIRA issue ([ROOT-9040](https://sft.its.cern.ch/jira/browse/ROOT-9040)) to address this problem.

For now, I recommend just setting the proper types for the vectors you pass as pointers to ROOT in Python, and add `input()` to get a pause for user input before exiting. I believe the cause of the crash could be an issue at tear down rather than being related to the problem that vector types are mismatched.

Cheers,  
—Guilherme

---

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [October 10, 2017, 5:13pm UTC](https://root-forum.cern.ch/t/pyroot-tmultigraph-segmentation-fault/26263/26 "2017-10-10T17:13:32Z")

</div>

Thanks for the investigation. I selected to watch the bug. I will definitely try to use “proper” types although this seems to go against the python ideology. As for adding `input()` this is not always a reasonable solution as some scripts were designed to be run automatically with no user interaction. At the moment we are avoiding the `TMultiGraph::GetListOfGraphs` method as that seems to be involved.

---

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [October 12, 2017, 10:00pm UTC](https://root-forum.cern.ch/t/pyroot-tmultigraph-segmentation-fault/26263/27 "2017-10-12T22:00:07Z")

</div>

I ran into the issue of “proper” types again and had to reteach myself what was learned above. I wanted to clarify the situation for myself and others who might run into this. At the moment the `dtype` of the two numpy arrays passed to TGraph must match. In addition, only certain `dtype` values produce reasonable output:

| Type | Constructor Chosen | Output |
| --- | --- | --- |
| int32 | int\* | Good |
| int64 | double\* | Bad |
| float32 | int\* | Bad |
| float64 | double\* | Good |

_\* The constructor chosen may not be correct, but is an educated guess based on above discussions._

Therefore the default type for integer arrays on 64-bit machine (int64) will not produce reasonable output.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [October 26, 2017, 10:14pm UTC](https://root-forum.cern.ch/t/pyroot-tmultigraph-segmentation-fault/26263/28 "2017-10-26T22:14:39Z")

</div>

Closed on October 26, 2017, 10:14pm UTC

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

[Previous page](https://root-forum.cern.ch/t/pyroot-tmultigraph-segmentation-fault/26263.md?page=1)
