-
Notifications
You must be signed in to change notification settings - Fork 148
Open
Description
A lock should be added when calling generatePointCloud, or the addresses of the vectors may shift when other threads execute the push_back operation.
This is especially likely to happen in a device where the memory is limited and the memory block allocated initially is not large enough. If it happens, a segmentation fault will result.
Wrong:
for ( size_t i=lastKeyframeSize; i<N ; i++ )
{
PointCloud::Ptr p = generatePointCloud( keyframes[i],semanticImgs_color[i], semanticImgs[i],colorImgs[i], depthImgs[i] );
*KfMap += *p;
*globalMap += *p;
}
A possible correction:
for ( size_t i=lastKeyframeSize; i<N ; i++ )
{
unique_lock<mutex> lck(keyframeMutex);
PointCloud::Ptr p = generatePointCloud( keyframes[i],semanticImgs_color[i], semanticImgs[i],colorImgs[i], depthImgs[i] );
*KfMap += *p;
*globalMap += *p;
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels