I am just tracking down a segmentation fault I am encountering wth the ITKTextureFeature modules instantiated with VectorImages.
I am tracking it down to using move operations of the VariableLengthVector:
It appears related to previously a deep copy was done, but now the move assignment is keeping the data to memory which has been released for a “GetPixel” type operation… Still looking deeper…
The assignment operator very nicely separate out the cases:
There may be some things suspicious with the move constructor. But I think it’s OK for the rvalue reference to be set to manage it’s own memory and a nullptr. The problem I see is what is the intent of the following code:
VariableLengthVectorType v = vector_image->GetPixelIndex(idx);
The constructor vs the assignment operator have different behavior. This is actually a call to the move constructor, where v with reference the image buffer. But if it was a call to the assignment operator, the vector v, would not be a proxy, and would have it’s own memory, so it would be a deep copy. This may result in un intended aliasing.
This is a complicated situation that needs a little more examination and verification.