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


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

#include <iostream>

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

int main(void)
#if 0
  TFile * file = new TFile("testBad.root", "READ");
  TFile * file = new TFile("testGood.root", "READ");
  TParameter<double>* par = dynamic_cast<TParameter<double>*>(gDirectory->Get("xMin"));
  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 (4.8 KB)
testGood.root (4.8 KB)

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.