fix(core): concurrent access errors with GDCM when accessing to DICOM data from different threads
Description
GDCM "SmartPointer" are not thread safe: construction, copy, assignment and deletion of two separates gdcm::SmartPointer<>
that share the same internal pointer in different thread will lead to catastrophic end, either crash, either random corruption of data. A quick look at GDCM code (gdcmSmartPointer.h
and gdcmObject.h
) confirms this.
Thus, recursive mutex has been added to some strategic points to ensure that all increments and decrements of the GDCM reference counters are done synchronously.
BTW, this is not ideal, they may be a performance impact, because of the "lock" and because of the use of recursive mutex, but this should sanitize a bit the GDCM usage.
we may one day try to better encapsulate the methods that really requier
gdcm::SmartPointer<>
to reduce the critical section. We may also refactor a bitfiducial_series
that uses extensivelygdcm::SmartPointer<>
and even expose it in the header, violating the original pimp design.
Results
sight::data::ut::dicom_mt_test
should fail without the fix (commit 06a8852c) and pass with (commit 21b6680c).
How to test it?
-
data_ut
should pass entirely. - Try to test with applications that make use of DICOM properties.
Related issue(s)
Closes #1236 (closed)