minMaxIdx() seems to clobber stack (Bug #1327)


Added by Nicu Stiurca over 13 years ago. Updated almost 13 years ago.


Status:Cancelled Start date:
Priority:Blocker Due date:
Assignee:Vadim Pisarevsky % Done:

0%

Category:core
Target version:2.4.0
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

When looping over rows in a Mat, and calling minMaxIdx() on the row, the loop counter gets clobbered, causing an infinite loop. See the attached source to reproduce.

Running on Ubuntu 9.04.3 x64, gcc version 4.4.3.

PS: I suspect this may actually be a GCC bug, but that's much less likely than it being a bug with minMaxIdx().


minmaxidx-bug.cpp - source code to reproduce (531 Bytes) Nicu Stiurca, 2011-08-20 12:10 am


Associated revisions

Revision 0daac6fd
Added by Roman Donchenko over 11 years ago

Merge pull request #1327 from alalek:ocl_master_tests_fix

History

Updated by Vadim Pisarevsky over 13 years ago

The code is incorrect. Any matrix, even if it's single-row or single-column matrix, has 2 dimensions. Thus, you need to allocate 2 elements for index.

...
for(int r=0; r<dists.rows; ++r) {
        double minVal;
        int minIdxr2;
        cv::minMaxIdx(dists.col(r), &minVal, NULL, minIdx);
        cout << 0 << " " << minVal << " " << minIdxr0 << " " << minIdxr1 << endl;
    }
...
  • Status changed from Open to Done
  • (deleted custom field) set to invalid

Updated by Andrey Kamaev almost 13 years ago

  • Status changed from Done to Cancelled
  • Target version set to 2.4.0

Also available in: Atom PDF