Project

General

Profile

Bug #1761

TRefArray can not be used in multithread mode

Added by Karadzhov, Yordan over 8 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Tracker
Target version:
-
Start date:
28 September 2015
Due date:
% Done:

100%

Estimated time:
Workflow:
New Issue

Description

Apparently TRefArray does nasty things when allocating memory and in the multithread mode we get random segfaults. This is actually explained very well in the comments at the beginning of the source file:

https://root.cern.ch/doc/master/TRefArray_8cxx_source.html#l00282

- All elements of a TRefArray must be set in the same process,
In particular, one cannot modify some elements of the array in
a different process.

TRefArray can not switch to new TProcessID if they already contain objects.

If you want to keep the data structure as it is, there will be no way to run the reconstruction in multithread mode.

However it seems to me that there is a solution, suggested again in the comments of the source file

Use an array of TRef when one of the above restrictions is met.

It will be even better if we use std::vector<TRef>

#1

Updated by Karadzhov, Yordan over 8 years ago

  • Category set to Tracker
#2

Updated by Dobbs, Adam over 8 years ago

Moving to a std::vector<TRef> seems like a good idea. I would ideally like to make a wrapper class, MAUS::CrossLink or something, to wrap it in case we decide to change the implementation again. I will get to it when I can, hopefully soon...

#3

Updated by Karadzhov, Yordan over 8 years ago

Just to keep the record.
Replacing TReffArray with std::vector<TRef> doesn't solve the problem. However I found here:
https://root.cern.ch/phpBB3/viewtopic.php?f=3&t=19325&p=82753&hilit=TThread%3A%3AInitialize#p82753

that in ROOT one have to call the "magical" static function

TThread::Initialize()

in order to enable the thread support. This seems to solve my problem entirely.

#4

Updated by Karadzhov, Yordan over 8 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF