Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connectedComponentsWithStats produces a segfault in the latest release (4.5.5.62) #604

Closed
Dobiasd opened this issue Jan 3, 2022 · 4 comments

Comments

@Dobiasd
Copy link

Dobiasd commented Jan 3, 2022

The following minimal example finishes with exit code 139 (interrupted by signal 11: SIGSEGV):

import cv2
import numpy as np

img = np.zeros((240, 320, 1), np.uint8)

cv2.connectedComponentsWithStats(img, connectivity=4)
cv2.connectedComponentsWithStats(img, connectivity=4)

With the previous release of opencv-python (4.5.4.60) this worked fine.

Here is a Dockerfile to reproduce the crash:

FROM python:3.9.9

RUN apt-get update && apt-get install -y \
  libglib2.0-0 \
  libgl1-mesa-glx \
  build-essential \
  && rm -rf /var/lib/apt/lists/*

# With the old opencv-python==4.5.4.60 things are fine.
RUN pip install --no-cache-dir numpy==1.22.0 opencv-python==4.5.5.62

RUN echo "import cv2" > main.py
RUN echo "import numpy as np" >> main.py
RUN echo "img = np.zeros((240, 320, 1), np.uint8)" >> main.py
RUN echo "cv2.connectedComponentsWithStats(img, connectivity=4)" >> main.py
RUN echo "cv2.connectedComponentsWithStats(img, connectivity=4)" >> main.py

RUN python main.py

Result:

Segmentation fault (core dumped)
@Dobiasd
Copy link
Author

Dobiasd commented Jan 3, 2022

I don't know if relevant, but when installing 4.5.4.60, pip prints:

Collecting opencv-python==4.5.4.60
  Downloading opencv_python-4.5.4.60-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (60.3 MB)

While when installing 4.5.5.62, it prints:

Collecting opencv-python==4.5.5.62
  Downloading opencv_python-4.5.5.62-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (60.4 MB)

(cp36-abi3 instead of cp39-cp39)

Maybe this is related to the problem.

@skvark
Copy link
Member

skvark commented Jan 3, 2022

Duplicate of #602 and opencv/opencv#21366.

Cannot be fixed here, the issue is in C++ code.

(cp36-abi3 instead of cp39-cp39)

That is expected due to recent changes. See https://www.python.org/dev/peps/pep-0384/ for more info.

@skvark skvark closed this as completed Jan 3, 2022
@Dobiasd
Copy link
Author

Dobiasd commented Jan 3, 2022

Ah, ok, thanks. 👍

@yanggyu17
Copy link

it works
opencv-python 4.5.4.60
thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants