Hello,
I might be overlooking something obvious here, but could someone please tell me why the following segfaults?
std::array<TObject*, 2> arr;
arr[0] = new TObject();
arr[1] = new TObject();
TFile f("foo.root", "RECREATE");
f.WriteObject(&arr, "array");
f.Close();
TFile ff("foo.root");
std::array<TObject*, 2> *arr2 = nullptr;
ff.GetObject("array", arr2); // Segfaults here
std::cout << arr2 << std::endl;
Output:
*** Break *** segmentation violation
===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0 0x00007f6613dd107a in __GI___waitpid (pid=27546, stat_loc=stat_loc
entry=0x7ffe0ac4b380, options=options
entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:29
#1 0x00007f6613d49fbb in do_system (line=<optimized out>) at ../sysdeps/posix/system.c:148
#2 0x00007f6615002a92 in TUnixSystem::StackTrace() () from /home/ahmad/biodynamo/build/third_party/root/lib/libCore.so
#3 0x00007f6615005383 in TUnixSystem::DispatchSignals(ESignals) () from /home/ahmad/biodynamo/build/third_party/root/lib/libCore.so
#4 <signal handler called>
#5 0x0000000000000002 in ?? ()
#6 0x00007f6614fa5521 in TClass::Destructor(void*, bool) () from /home/ahmad/biodynamo/build/third_party/root/lib/libCore.so
#7 0x00007f661479b9e6 in TBufferFile::ReadFastArray(void**, TClass const*, int, bool, TMemberStreamer*, TClass const*) () from /home/ahmad/biodynamo/build/third_party/root/lib/libRIO.so
#8 0x00007f6614a13c6e in int TStreamerInfo::ReadBuffer<char**>(TBuffer&, char** const&, TStreamerInfo::TCompInfo* const*, int, int, int, int, int) () from /home/ahmad/biodynamo/build/third_party/root/lib/libRIO.so
#9 0x00007f6614863403 in TStreamerInfoActions::GenericReadAction(TBuffer&, void*, TStreamerInfoActions::TConfiguration const*) () from /home/ahmad/biodynamo/build/third_party/root/lib/libRIO.so
#10 0x00007f66147a1d9e in TBufferFile::ReadClassBuffer(TClass const*, void*, TClass const*) () from /home/ahmad/biodynamo/build/third_party/root/lib/libRIO.so
#11 0x00007f661483b05f in TKey::ReadObjectAny(TClass const*) () from /home/ahmad/biodynamo/build/third_party/root/lib/libRIO.so
#12 0x00007f66147de69e in TDirectoryFile::GetObjectChecked(char const*, TClass const*) () from /home/ahmad/biodynamo/build/third_party/root/lib/libRIO.so
#13 0x0000000000401f6d in void TDirectory::GetObject<std::array<TObject*, 2ul> >(char const*, std::array<TObject*, 2ul>*&) ()
#14 0x0000000000401c69 in main ()
===========================================================
Using std::vector<TObject*> and adding this to my selection.xml for genreflex seems to work fine. If I try to add std::array<TObject*, 2> to my selection.xml I get an error saying that this should be working “transparently” and therefore should not have it in my selection.xml
Any ideas what is going wrong?
Best,
Ahmad
ROOT Version: v6.18/04
Platform: Ubuntu 16.04
Compiler: GCC 5.5