Skip to content

Bug in resize for 5 channels images #16501

Closed

Description

@bonlime
System information (version)
  • OpenCV => 4.2
  • Operating System / Platform => Ubuntu 16.04
  • Compiler => ❔
Detailed description

I'm using python bindings for opencv and found a bug with resizing images with 5 channels. It works fine for any other number of channels.
I've also checked previous versions and it works in 4.1.1. So the bug should be very recent

Steps to reproduce
import numpy as np
import cv2
arr = np.ones((1200, 1200, 5), dtype=np.uint8)
cv2.resize(arr, (512, 512))

for me it fails with
double free or corruption (!prev)

Activity

  1. changed the title [-]Resize images not working[/-] [+]Bug in resize for 5 channels images[/+] on Feb 4, 2020
  2. alalek commented on Feb 4, 2020

    @alalek
    Member

    Reproduced without Python:

        Mat src(Size(1200, 1200), CV_MAKETYPE(CV_8U, 5), Scalar::all(0));
        Mat dst;
        resize(src, dst, Size(512, 512));
    

    Valgrind:

    ==31182== Invalid write of size 8
    ==31182==    at 0x510B6C3: _mm_storeu_si128 (emmintrin.h:721)
    ==31182==    by 0x510B6C3: cv::hal_baseline::v_store(int*, cv::hal_baseline::v_int32x4 const&) (intrin_sse.hpp:1558)
    ==31182==    by 0x538CB59: cv::HResizeLinearVecU8_X4::operator()(unsigned char const**, int**, int, int const*, short const*, int, int, int, int, int) const (resize.cpp:1698)
    ==31182==    by 0x53BF4A2: cv::HResizeLinear<unsigned char, int, short, 2048, cv::HResizeLinearVecU8_X4>::operator()(unsigned char const**, int**, int, int const*, short const*, int, int, int, int, int) const (resize.cpp:1800)
    ==31182==    by 0x53B6B63: cv::resizeGeneric_Invoker<cv::HResizeLinear<unsigned char, int, short, 2048, cv::HResizeLinearVecU8_X4>, cv::VResizeLinear<unsigned char, int, short, cv::FixedPtCast<int, unsigned char, 22>, cv::VResizeLinearVec_32s8u> >::operator()(cv::Range const&) const (resize.cpp:2137)
    
  3. bonlime commented on Feb 5, 2020

    @bonlime
    Author

    Thanks for fixing this so fast!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected: 3.4bugcategory: imgprocconfirmedpriority: normal

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions