Possible filter2D bug (Bug #2576)
Description
The function cv::filter2D has a bug related to its memory management. I am working on OS X 10.6.8, using opencv2.4.0.
The execution of this code:
for(i=0; i < n_iter; i++) { std::cout << "Normalize_a, iteration " << i << std::endl; Utils::print_info(tmp, "TMP"); cv::Mat tmp2(tmp.rows, tmp.cols, tmp.type()); Utils::print_info(tmp2, "TMP2"); Utils::print_info(flipped_dog, "Flipped dog"); std::cout << "Applying filter 2D" << std::endl; std::cout << anchor << std::endl; cv::filter2D(tmp, tmp2, -1, flipped_dog, anchor, 0, border_mode); std::cout << "Filter 2D applied" << std::endl; tmp = tmp + tmp2 - 0.01; cv::threshold(tmp, tmp, 0, 0, cv::THRESH_TOZERO); } // for i, iterations
according to the image (tmp, tmp2) size, results in this output
Normalize attn, iteration 0 Printing info on cv::Mat TMP rows: 157, cols: 250 min - max: 0 - 1 Printing info on cv::Mat TMP2 rows: 157, cols: 250 min - max: 0.0217404 - 1 Printing info on cv::Mat Flipped dog rows: 79, cols: 79 min - max: -5.70341e-05 - 0.00397742 Applying filter 2D [39, 39]
followed by
va_main(97201) malloc: *** error for object 0x1010ca200: incorrect checksum for freed object - object was probably modified after being freed. *** set a breakpoint in malloc_error_break to debug Abort trap
I will try and modify the code (it is not the best you might desire), but it is perfectly legal (isn't it?).
Regards
History
Updated by Kirill Kornyakov over 12 years ago
Antonio, we need you to do the following:
- Try to reproduce the bug with OpenCV 2.4.3
- Attach the full sample together with input images
And what do you mean by modifying the code? If you want to provide a fix in the form of pull request, that would be great!
- Category set to imgproc, video
- Priority changed from High to Low
- Assignee set to antonio sesto
- Subject changed from filter2D bug to Possible filter2D bug
Updated by antonio sesto over 12 years ago
I wrote the procedure from scratch and the bug disappeared. Now everything is fine.
Updated by Kirill Kornyakov over 12 years ago
OK, thanks, cancelling the ticket.
- Target version set to 2.4.4
- Status changed from Open to Cancelled
Updated by Andrey Kamaev about 12 years ago
- Target version changed from 2.4.4 to 2.4.3.1