# Root2csv segmentation fault for Geant4 merged .root file

**URL:** <https://root-forum.cern.ch/t/root2csv-segmentation-fault-for-geant4-merged-root-file/56052>\
**Category:** ROOT\
**Tags:** root\
**Created:** [August 16, 2023, 9:37pm UTC](https://root-forum.cern.ch/t/root2csv-segmentation-fault-for-geant4-merged-root-file/56052 "2023-08-16T21:37:40Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanBenjaminOxos](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danbenjaminoxos/32/34032_2.png) [@DanBenjaminOxos](https://root-forum.cern.ch/u/DanBenjaminOxos)\
**Post date:** [August 16, 2023, 9:37pm UTC](https://root-forum.cern.ch/t/root2csv-segmentation-fault-for-geant4-merged-root-file/56052/1 "2023-08-16T21:37:41Z")

</div>

I’m trying to use root2csv, as in this post.

> [@Converting root file to csv using root2csv](https://root-forum.cern.ch/t/converting-root-file-to-csv-using-root2csv/42583/5):
>
> ok. so, first a few clarifying things. root-ls, root2csv, … all the commands from [go-hep.org/x/hep](https://go-hep.org/x/hep) are written in [Go](https://golang.org). Go is a compiled programming language, so one needs a compiler (e.g. one that can be installed from [golang.org](https://golang.org)) to compile Go source code into an executable for a given operating system + architecture (e.g.: linux + 64bits machine). go get go-hep.org/x/hep/cmd/root2csv will fetch the Go code for root2csv, compile it and install the resulting binary under some directory (by…

I’m running a Geant4 program that runs in multithreading. If I generate the root files as normal outputs, it will generate say “output\_t#.root” for each thread #. I can manually merge the files after the fact using hadd, and then run root2csv to get a csv output.

However, for efficiency I would like to have the multiple threads merged. If I enable the command below using the G4AnalysisManager, I do get a single output.root file.

//Merge Multi-threaded root files into one  
man-\>SetNtupleMerging(true);

However, if I try to run root2csv on this, I get a segmentation violation.

panic: runtime error: invalid memory address or nil pointer dereference  
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x931c61]

Anyone know how to work around this?

---

<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:** [August 16, 2023, 10:06pm UTC](https://root-forum.cern.ch/t/root2csv-segmentation-fault-for-geant4-merged-root-file/56052/2 "2023-08-16T22:06:11Z")

</div>

hi there,

could you post a link to a ROOT file that makes `root2csv` panic ?  
(also, which version of `root2csv` are you using ?)

---

<div class="post-metadata">

**Author:** ![DanBenjaminOxos](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danbenjaminoxos/32/34032_2.png) [@DanBenjaminOxos](https://root-forum.cern.ch/u/DanBenjaminOxos)\
**Post date:** [August 17, 2023, 1:15pm UTC](https://root-forum.cern.ch/t/root2csv-segmentation-fault-for-geant4-merged-root-file/56052/3 "2023-08-17T13:15:10Z")

</div>

Here’s a link to a merged root file that I can open in root, but fails on trying to use root2csv.

> **[output\_1.root](https://drive.google.com/file/d/1GvIGCNzO0zoudFxjm8OiVT_bbS5ryPU9/view?usp=sharing)**
>
> Google Drive file.

I’m not sure how to check the version of root2csv, but I tried yesterday on whatever the latest version was when downloading using the instructions you shared (with @latest).

---

<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:** [August 29, 2023, 8:12am UTC](https://root-forum.cern.ch/t/root2csv-segmentation-fault-for-geant4-merged-root-file/56052/4 "2023-08-29T08:12:16Z")

</div>

apologies for the belated answer.  
I didn’t get an email notification for your answer.

I’ll investigate (at a quick glance, it seems it’s coming from how baskets are organized with this modus operandi. `uproot` seems to get those correctly, so there’s hope `groot` can do that as well)

---

<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 6, 2023, 9:40am UTC](https://root-forum.cern.ch/t/root2csv-segmentation-fault-for-geant4-merged-root-file/56052/5 "2023-09-06T09:40:49Z")

</div>

hi there,

PR #990 should fix it.  
(it will appear shortly (1-2 days) in the next Go-HEP version)

> <https://github.com/go-hep/hep/pull/990>
>
> This CL adds proper handling of Geant4 files produced in multithreaded mode (and… merged).
> 
> Fixes #989.

---

<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 8, 2023, 4:51pm UTC](https://root-forum.cern.ch/t/root2csv-segmentation-fault-for-geant4-merged-root-file/56052/6 "2023-09-08T16:51:33Z")

</div>

@DanBenjaminOxos it’s done and published 🙂

- [Go HEP release 0.34.0 - go-hep](https://go-hep.org/news/release-0.34.0/)

---

<div class="post-metadata">

**Author:** ![DanBenjaminOxos](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danbenjaminoxos/32/34032_2.png) [@DanBenjaminOxos](https://root-forum.cern.ch/u/DanBenjaminOxos)\
**Post date:** [September 8, 2023, 5:13pm UTC](https://root-forum.cern.ch/t/root2csv-segmentation-fault-for-geant4-merged-root-file/56052/7 "2023-09-08T17:13:55Z")

</div>

Nice work. I’ll give it a go.

---

<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 18, 2023, 11:59am UTC](https://root-forum.cern.ch/t/root2csv-segmentation-fault-for-geant4-merged-root-file/56052/8 "2023-09-18T11:59:40Z")

</div>

@DanBenjaminOxos any news ?

(my policy has always been to only advertise `groot` stuff _when_ `ROOT/C++` didn’t provide a satisfactory answer. or when asked to. and I’ve always been very clear about the Go-ish-ness of `groot`.)

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [September 18, 2023, 1:28pm UTC](https://root-forum.cern.ch/t/root2csv-segmentation-fault-for-geant4-merged-root-file/56052/9 "2023-09-18T13:28:33Z")

</div>

@sbinet et might make sense to set up your own support forum and redirect people there? It might be worthwhile for people to understand that they are not connected to ROOT - i.e. once you decide to become a lumberjack or whatever 🙂 we won’t be able to support them… Thanks!

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [September 18, 2023, 1:28pm UTC](https://root-forum.cern.ch/t/root2csv-segmentation-fault-for-geant4-merged-root-file/56052/10 "2023-09-18T13:28:39Z")

</div>

Closed on September 18, 2023, 1:28pm UTC


