alicevision / CCTag

Detection of CCTag markers made up of concentric circles.
https://cctag.readthedocs.io
Mozilla Public License 2.0
351 stars 87 forks source link

[bug] CV_DbgAssert is raised in cvRecordedCany() ( Maybe buffer overrun ) #189

Closed DDDsasaki closed 2 years ago

DDDsasaki commented 2 years ago

Describe the bug

CV_DbgAssert is raised in cvRecordedCany() ( Maybe buffer overrun )

To Reproduce

I have read https://cctag.readthedocs.io/en/latest/api/usage.html and wrote test code.

int main(void) {
    const std::size_t nCrowns = 3;
    cctag::Parameters params(nCrowns);
    params.setUseCuda(false);

    cv::Mat src = cv::imread("01.png");
    cv::Mat graySrc;
    cv::cvtColor(src, graySrc, CV_BGR2GRAY);

    // choose a cuda pipe
    const int pipeId = 0;
    // on arbitrary id for the frame
    const int frameId = 0;

    // process the image
    boost::ptr_list<cctag::ICCTag> markers;
    cctag::cctagDetection(markers, pipeId, frameId, graySrc, params);   // CV_DbgAssert is raised HERE!!

Expected behavior

CV_DbgAssert is not raised.

Screenshots

CCTag_issue

Log

Desktop (please complete the following and other pertinent information):

vcpkg.json is below

{
  "name": "use-cctag",
  "version": "0.0.1",
  "dependencies": [
    "cctag"
  ],
  "builtin-baseline": "611804964272028b346369caac76dd35a5e084cb",
  "overrides": [
    { "name": "cctag", "version": "1.0.1" }
  ]
}

Additional context

In CCTag code, I found the buffer overrn. (may be...)

src/cctag/filter/cvRecode.cpp

178 :   for( i = 0; i <= size.height; i++ )         // Maybe buffer overrun
179 :   {
180 :     int* _mag    = mag_buf[( i > 0 ) + 1] + 1;
181 :     const short* _imgDX = imgDX.ptr<short>(i);    // CV_DbgAssert HERE

It seems the for-loop should be

178 :   for( i = 0; i < size.height; i++ )

note: If release build, CV_DbgAssert is ignored.

Thank you.

DDDsasaki commented 2 years ago

I have found that this issue is resolved at commit 9c3de8da7652663f290b6c715af579e149e75557. Sorry. I hope version 1.0.2 will be released.

simogasp commented 2 years ago

I hope version 1.0.2 will be released.

it's done

DDDsasaki commented 2 years ago

I hope version 1.0.2 will be released.

it's done

Thank you !