# Migrating GUI Elements from ROOT5 to ROOT6

**URL:** <https://root-forum.cern.ch/t/migrating-gui-elements-from-root5-to-root6/60310>\
**Category:** ROOT\
**Tags:** graphics, root\
**Created:** [July 24, 2024, 9:05am UTC](https://root-forum.cern.ch/t/migrating-gui-elements-from-root5-to-root6/60310 "2024-07-24T09:05:27Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![NSos](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/aeb1de/32.png) [@NSos](https://root-forum.cern.ch/u/NSos)\
**Post date:** [July 24, 2024, 9:05am UTC](https://root-forum.cern.ch/t/migrating-gui-elements-from-root5-to-root6/60310/1 "2024-07-24T09:05:27Z")

</div>

* * *

_Please read [tips for efficient and successful posting](https://root-forum.cern.ch/t/tips-for-efficient-and-successful-posting/28292) and [posting code](https://root-forum.cern.ch/t/posting-code-read-this-first/28293)_

_Please fill also the fields below. Note that **`root -b -q`** will tell you this info, and starting from 6.28/06 upwards, you can call **`.forum bug`** from the ROOT prompt to pre-populate a topic._

_ROOT Version:_ 6.32.02  
_Platform:_ Debian Linux 6.10  
_Compiler:_ g++ 12.2

Hi, I am currently trying to migrate a set of codes my collaboration has been using for a long time from ROOT5 to ROOT6. If I compile the codes in ROOT 5.34/38, everything runs flawlessly, as it ever did. If I try ROOT 6.32.02, however, several different elements of the GUI are broken. The codes are a TApplication with a user interface for browsing detector signals, and for ROOT6 compilation I cannot use zoom on TPads. Furthermore, the GUI uses some colored markers, which disappear when clicked on after ROOT6 compilation. Lastly, after browsing several signals, the program segfaults with

_free(): invalid next size (fast)_

which never happens in ROOT5 compilation. I have tried troubleshooting the segfault part of it myself in hopes that it would lead me to other problems, but I could not find the issue. I have tried using Valgrind 3.19 with root-suppression, but it’s that annoying case where the crash disappears in Valgrind. I have also tried using GDB 13.1, but as often happens with segfaults, I get a different crash everytime, so GDB backtrace did not yield anything useful.

I did not post any sample codes here because the code is rather large, and the GDB-identified source of the segfault drifts around (as stray pointers do). Moreover, since I would like to restore graphical functionality (like zooming), I was not sure which of the many parts of the code could have changed behaviour between ROOT versions to cause it.

I tried reading ROOT versioning history of ROOT6 for hints, but also didnt identify anything obvious. I would appreciate any hints on what sort of graphical changes occurred between the two ROOT versions I try that in your experience could result in such behaviour, and then I can try to troubleshoot it from there. I can post corresponding snippets of the code as well for anything you would expect to go astray based on the description of the problem. Thanks in advance for any help!

* * *

---

<div class="post-metadata">

**Author:** ![devajith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/devajith/32/37165_2.png) [@devajith](https://root-forum.cern.ch/u/devajith)\
**Post date:** [July 24, 2024, 9:35am UTC](https://root-forum.cern.ch/t/migrating-gui-elements-from-root5-to-root6/60310/2 "2024-07-24T09:35:04Z")

</div>

Hi @NSos, welcome back to the forum. I’m not an expert on graphics.

I will add our graphics expert @couet in the loop, but he’s on vacation this week.

I know you mentioned that the code is rather large, but would it be possible for you to submit small snippets of code or the logs? This would make it easier for us to pinpoint exactly where the problem is.

---

<div class="post-metadata">

**Author:** ![NSos](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/aeb1de/32.png) [@NSos](https://root-forum.cern.ch/u/NSos)\
**Post date:** [July 24, 2024, 10:21am UTC](https://root-forum.cern.ch/t/migrating-gui-elements-from-root5-to-root6/60310/3 "2024-07-24T10:21:49Z")

</div>

That’s brilliant, thanks! I will wait for him to get back then.

Here is a [link to the code](https://www.dropbox.com/scl/fi/2how5hy82ha2bxrqvwpwv/gui.cc?rlkey=n7tcdeavebz2jjyc74nm9dozm&st=w9x5ke7v&dl=0) stored on my Dropbox. The code is not self-sufficient, so it probably won’t compile (and anyhow, it would require signal data file inputs to run), but it will perhaps be sufficient to get the idea of what we are doing.

---

<div class="post-metadata">

**Author:** ![NSos](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/aeb1de/32.png) [@NSos](https://root-forum.cern.ch/u/NSos)\
**Post date:** [July 24, 2024, 11:40am UTC](https://root-forum.cern.ch/t/migrating-gui-elements-from-root5-to-root6/60310/4 "2024-07-24T11:40:13Z")

</div>

One more thing, based on GDB backtrace, crashes seem to often cluster around line 1658, where TCanvas objects are cleared. I have tried tracking their behaviour through the code, but it seems fine to my unprofessional eye (and again, it works fine in ROOT5!). And also, it’s not just the crash, but also GUI not behaving correctly that I would like to fix, and I doubt it’s TCanvas clearing that causes zooming to malfunction (although with memory allocation problems, who knows…).

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [July 25, 2024, 2:04pm UTC](https://root-forum.cern.ch/t/migrating-gui-elements-from-root5-to-root6/60310/5 "2024-07-25T14:04:54Z")

</div>

Let’s split the problems and face them one by one.

I would suggest that you create a simple example containing just one TPad, where zoom works on ROOT5 but not on ROOT6. It should be a self-contained snippet of code.

Then, a separate one where the colored marker disappear.

For the segfault, two options:

- I tried your dropbox link, but it is missing gui.h, PSADetector.h etc. so I cannot debug myself. If you add the rest of the files, I can try to help.
- Debug yourself with a ROOT version built from source in ‘debug’ mode, not in ‘release mode’, which is the usual one when you download from binary.

---

<div class="post-metadata">

**Author:** ![NSos](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/aeb1de/32.png) [@NSos](https://root-forum.cern.ch/u/NSos)\
**Post date:** [July 25, 2024, 2:39pm UTC](https://root-forum.cern.ch/t/migrating-gui-elements-from-root5-to-root6/60310/6 "2024-07-25T14:39:06Z")

</div>

Hi, thanks for having a look. Thanks also for the offer of having a read, but there are other dependencies, which involve my collaboration’s analysis codes, which I am hesitant to share publicly. I also have simply inherited this code, so I was planning on making test codes only as a last resort, as that would involve a lot of digging through what’s already there.

A debug mode is a great idea though, thanks! I did not realize that ROOT offers such functonality. My ROOT is installed from source, so I will recompile it. Would I simpy need to set compilation flag _CMAKE\_BUILD\_TYPE=“Debug”_? Or is there more to it?

In coming to these forums, I mostly hoped to check whether there are some known major graphical changes between the versions, which have previously compromised functionality like zooming, so that I could use that as guides for debugging myself.

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [July 25, 2024, 2:40pm UTC](https://root-forum.cern.ch/t/migrating-gui-elements-from-root5-to-root6/60310/7 "2024-07-25T14:40:36Z")

</div>

> [@NSos](#):
>
> Would I simpy need to set compilation flag _CMAKE\_BUILD\_TYPE=“Debug”_? Or is there more to it?

Yes, that’s it.

You can also use an IDE to help yourself, see eg: [Coding in ROOT with the horsepower of an F1 - ROOT](https://root.cern/blog/code-horsepower-f1/)

---

<div class="post-metadata">

**Author:** ![NSos](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/aeb1de/32.png) [@NSos](https://root-forum.cern.ch/u/NSos)\
**Post date:** [July 25, 2024, 2:45pm UTC](https://root-forum.cern.ch/t/migrating-gui-elements-from-root5-to-root6/60310/8 "2024-07-25T14:45:56Z")

</div>

Brilliant, thanks! I will give this a try, and will post a solution if I find it. In the meanwhile, if anyone on the team happens to remember some similar issues cropping up previously, I would still appreciate any hints.

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [July 25, 2024, 2:47pm UTC](https://root-forum.cern.ch/t/migrating-gui-elements-from-root5-to-root6/60310/9 "2024-07-25T14:47:01Z")

</div>

> [@NSos](#):
>
> but there are other dependencies, which involve my collaboration’s analysis codes, which I am hesitant to share publicly

You could remove those files and comment out the part of the code that uses those classes from within the mainwindow.

I don’t think there is any change in zooming between 5 and 6. But as said, try to create a minimal reproducer script with a TPad to facilitate giving you more help.

Another option would be to check the release notes.  
For example, in 6.04: It was possible to interactively zoom outside the histograms’ limits. Protections have been added.

---

<div class="post-metadata">

**Author:** ![NSos](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/aeb1de/32.png) [@NSos](https://root-forum.cern.ch/u/NSos)\
**Post date:** [August 1, 2024, 2:43pm UTC](https://root-forum.cern.ch/t/migrating-gui-elements-from-root5-to-root6/60310/10 "2024-08-01T14:43:38Z")

</div>

@ferhue has looked at the issues I listed here via direct messages, and two main problems were identified. Firstly, functions that return pointers to objects like TMultiGraph had if/else clauses, which provided correct returns, but the end of the function itself had no _return NULL;_. After adding this, segfaults went away.

Secondly, axes were initialized with huge limits like 1e100. While I am unsure why this changes behaviour between ROOT versions, changing all instances of this to 1e4 has fixed axis behaviour.

Thanks again for huge help, @ferhue! Issue solved.

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [August 1, 2024, 3:02pm UTC](https://root-forum.cern.ch/t/migrating-gui-elements-from-root5-to-root6/60310/11 "2024-08-01T15:02:52Z")

</div>

> [@NSos](#):
>
> had if/else clauses, which provided correct returns, but the end of the function itself had no _return NULL;_. After adding this, segfaults went away.

That doesn’t sound correct, if the if-else had returns already, adding something at the end should not change anything, as it should be unreachable.

I believe the other problem with the crash/leak might be with calling gDirectory-\>Delete(“name”)  
as the name of TGraphs were not being initialized, they had all the same name, so nasty things could happen. So giving each TGraph a distinct name via SetName might prevent this. Or maybe it’s something different and it only happens from time to time due to a different reason.

---

<div class="post-metadata">

**Author:** ![NSos](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/aeb1de/32.png) [@NSos](https://root-forum.cern.ch/u/NSos)\
**Post date:** [August 1, 2024, 3:33pm UTC](https://root-forum.cern.ch/t/migrating-gui-elements-from-root5-to-root6/60310/12 "2024-08-01T15:33:02Z")

</div>

Hmm, that was my initial reaction, but then after adding that and changing those unsurprsingly-problematic large numbers, the code works properly. Previously it was essentially guaranteed to crash at several points, and now I have been looking at graphs for an hour, and no problems.

I have also added the SetName() functions for every instance of a declaration of a TGraph\*, TMultiGraph\* or TH1F\* in a function, but that hasn’t changed anything. It makes sense to me as a good practice though, so I will keep it there.

Either way, changing colossal numbers to more sensible ones definitely made a difference!

---

<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:** [August 15, 2024, 3:33pm UTC](https://root-forum.cern.ch/t/migrating-gui-elements-from-root5-to-root6/60310/13 "2024-08-15T15:33:40Z")

</div>

Closed on August 15, 2024, 3:33pm UTC

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