# gDirectory-\>Get crashes with: unsorted double linked list corrupted

**URL:** <https://root-forum.cern.ch/t/gdirectory-get-crashes-with-unsorted-double-linked-list-corrupted/32429>\
**Category:** Newbie\
**Created:** [January 24, 2019, 1:49pm UTC](https://root-forum.cern.ch/t/gdirectory-get-crashes-with-unsorted-double-linked-list-corrupted/32429 "2019-01-24T13:49:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![busa](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/d78d45/32.png) [@busa](https://root-forum.cern.ch/u/busa)\
**Post date:** [January 24, 2019, 1:49pm UTC](https://root-forum.cern.ch/t/gdirectory-get-crashes-with-unsorted-double-linked-list-corrupted/32429/1 "2019-01-24T13:49:00Z")

</div>

Hello,

I’m trying to use root for storing and retrieving of parameters. So I wrote some code to write data and now I would like to read them. My problem is, that when I open the (attached) file `testBad.root` for reading, enter the directory “parameters” and query for double valued parameter “xMin”, the program crashes with error

`malloc(): unsorted double linked list corrupted`  
`Aborted (core dumped)`

This doesn’t happen for the file `testGood.root`. Both files were created by the same program, the only difference between them is the order of double valued matrices _pp_ and _tem_ in the directory “parameters”. Also both files show properly using TBrowser.

To show the problem, I have compiled simple program

```auto
#include <iostream>

#include "root/TFile.h"
#include "root/TParameter.h"

int main(void)
{
#if 0
  TFile * file = new TFile("testBad.root", "READ");
#else
  TFile * file = new TFile("testGood.root", "READ");
#endif
  file->cd("parameters");
  TParameter<double>* par = dynamic_cast<TParameter<double>*>(gDirectory->Get("xMin"));
  file->Close();
  return 0;
}

```

with the command:  
`g++ -g -I/usr/include/glibmm-2.4 -I/usr/lib64/glibmm-2.4/include/ -I/usr/include/glib-2.0/ -I/usr/lib64/glib-2.0/include/ -o tiny tinyFile.cpp `root-config --cflags --glibs``

I’m running Fedora 29 with g++ 8.2.1 and ROOT 6.14/08 from Fedora repository.

Thanks in advance for any ideas.

[testBad.root](https://root-forum.cern.ch/uploads/default/original/3X/6/4/64016d6e62c8eb9d66eac2c9c9f1eef634757d44.root) (4.8 KB)  
[testGood.root](https://root-forum.cern.ch/uploads/default/original/3X/e/3/e31a38065f0ba2df94fd7667eef7562fd3adfa28.root) (4.8 KB)

---

<div class="post-metadata">

**Author:** ![busa](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/d78d45/32.png) [@busa](https://root-forum.cern.ch/u/busa)\
**Post date:** [January 25, 2019, 8:02am UTC](https://root-forum.cern.ch/t/gdirectory-get-crashes-with-unsorted-double-linked-list-corrupted/32429/2 "2019-01-25T08:02:49Z")

</div>

At the end I have figured out, that I had problem in the initialization of matrices. Due to mistake in `memcpy` I had half of the data added to matrix using `SetMatrixArray` uninitialized. Strangely enough, ROOT didn’t have any problem saving such corrupted data (uninitialized doubles) but after reopening the file for reading it crashed, both from the program and from the TBrowser.
