This repository was archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
This repository was archived by the owner on Nov 17, 2023. It is now read-only.
mxnet.image.imdecode crash if input a empty buffer #12868
Copy link
Copy link
Closed
Labels
Description
Description
mxnet.image.imdecode() will crash and python process will die if pass a empty bytes buffer to the function.
This looks like a opencv bug, but we should do validation to avoid crash the process.
Environment info (Required)
----------Python Info----------
('Version :', '2.7.15')
('Compiler :', 'GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)')
('Build :', ('default', 'Oct 2 2018 12:50:38'))
('Arch :', ('64bit', ''))
------------Pip Info-----------
('Version :', '18.0')
('Directory :', '/usr/local/lib/python2.7/site-packages/pip')
----------MXNet Info-----------
objc[37046]: Class CaptureDelegate is implemented in both /usr/local/opt/opencv/lib/libopencv_videoio.3.4.dylib (0x1179ed9d8) and /usr/local/lib/python2.7/site-packages/cv2/cv2.so (0x1257b02d0). One of the two will be used. Which one is undefined.
('Version :', '1.3.1')
('Directory :', '/Users/lufen/source/mxnet/python/mxnet')
Hashtag not found. Not installed from pre-built package.
----------System Info----------
('Platform :', 'Darwin-16.7.0-x86_64-i386-64bit')
('system :', 'Darwin')
('node :', 'f45c89cb5707.ant.amazon.com')
('release :', '16.7.0')
('version :', 'Darwin Kernel Version 16.7.0: Thu Jun 21 20:07:39 PDT 2018; root:xnu-3789.73.14~1/RELEASE_X86_64')
----------Hardware Info----------
('machine :', 'x86_64')
('processor :', 'i386')
machdep.cpu.extfeatures: SYSCALL XD 1GBPAGE EM64T LAHF LZCNT PREFETCHW RDTSCP TSCI
machdep.cpu.leaf7_features: SMEP ERMS RDWRFSGS TSC_THREAD_OFFSET BMI1 AVX2 BMI2 INVPCID SMAP RDSEED ADX IPT FPU_CSDS
machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX EST TM2 SSSE3 FMA CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC MOVBE POPCNT AES PCID XSAVE OSXSAVE SEGLIM64 TSCTMR AVX1.0 RDRAND F16C
machdep.cpu.brand_string: Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz
----------Network Test----------
Setting timeout: 10
Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.0190 sec, LOAD: 0.5909 sec.
Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0169 sec, LOAD: 0.5069 sec.
Timing for FashionMNIST: https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, DNS: 0.0214 sec, LOAD: 0.1385 sec.
Timing for Conda: https://repo.continuum.io/pkgs/free/, DNS: 0.0166 sec, LOAD: 0.0696 sec.
Timing for Gluon Tutorial(en): http://gluon.mxnet.io, DNS: 0.0540 sec, LOAD: 0.2254 sec.
Timing for Gluon Tutorial(cn): https://zh.gluon.ai, DNS: 0.0357 sec, LOAD: 0.0770 sec.
Build info (Required if built from source)
MXNet commit hash: 815f36c
Error Message:
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: OpenCV(3.4.3) /tmp/opencv-20181001-10090-v5zhfq/opencv-3.4.3/modules/imgcodecs/src/loadsave.cpp:737: error: (-215:Assertion failed) !buf.empty() && buf.isContinuous() in function 'imdecode_'
Abort trap: 6
Minimum reproducible example
>>> from mxnet import image as img
>>> buf = b''
>>> img.imdecode(buf, 1, True, None)
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: OpenCV(3.4.3) /tmp/opencv-20181001-10090-v5zhfq/opencv-3.4.3/modules/imgcodecs/src/loadsave.cpp:737: error: (-215:Assertion failed) !buf.empty() && buf.isContinuous() in function 'imdecode_'
Abort trap: 6
Steps to reproduce
What have you tried to solve it?
I have to validate buffer is not empty before pass to image.imdecode()