Fix a potential bug of ParallelLoopBodyWrapper::operator(Range) on 32-bit (Bugfix #3233)


Added by Peng Xiao over 11 years ago. Updated over 11 years ago.


Status:Done Start date:2013-08-23
Priority:Normal Due date:
Assignee:Vadim Pisarevsky % Done:

100%

Category:core
Target version:-
Affected version:branch '2.4' Operating System:Windows
Difficulty: HW Platform:x86
Pull request:

Description

        void operator()(const cv::Range& sr) const
        {
            cv::Range r;
            r.start = (int)(wholeRange.start +
                            ((size_t)sr.start*(wholeRange.end - wholeRange.start) + nstripes/2)/nstripes);
            r.end = sr.end >= nstripes ? wholeRange.end : (int)(wholeRange.start +
                            ((size_t)sr.end*(wholeRange.end - wholeRange.start) + nstripes/2)/nstripes);
            (*body)(r);
        }

On a 32-bit compiler the calculation may result in data (size_t) overflow when running some paralleled algorithms (which can safely run on a 64-bit compiler), resulting range is shaped to undefined values.
This bug is found when running OpenCV's Retina tutorial on 32bit VS2010.

Bugfix is sent:
https://github.com/Itseez/opencv/pull/1332


Associated revisions

Revision d1fba068
Added by Vadim Pisarevsky over 10 years ago

Merge pull request #3233 from niebles:master

History

Also available in: Atom PDF