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

imshow segfaults in 4.5.4.58 on Ubuntu 21.04 (x86_64, Python 3.9) #572

Closed
oseiskar opened this issue Oct 22, 2021 · 18 comments
Closed

imshow segfaults in 4.5.4.58 on Ubuntu 21.04 (x86_64, Python 3.9) #572

oseiskar opened this issue Oct 22, 2021 · 18 comments
Assignees
Labels

Comments

@oseiskar
Copy link

oseiskar commented Oct 22, 2021

Expected behaviour

Shows an image, like the version 4.5.3.56

Actual behaviour

Crashed with segfault

Steps to reproduce

  1. Create testimshow.py
import cv2
img = cv2.imread('myimage.png')
cv2.imshow('title', img)
cv2.waitKey(0)
  1. Create an image myimage.png in the same folder
  2. pip install opencv-python
  3. python testimshow.py
Segmentation fault (core dumped)

System info (Ubuntu 21.04) uname -a

Linux os-ThinkPad-T14s 5.11.0-38-generic #42-Ubuntu SMP Fri Sep 24 14:03:54 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Full log

(venv) os@17:39:55> pip install --force-reinstall opencv-python
Collecting opencv-python
  Using cached opencv_python-4.5.4.58-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (60.3 MB)
Collecting numpy>=1.19.3
  Using cached numpy-1.21.3-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.7 MB)
Installing collected packages: numpy, opencv-python
  Attempting uninstall: numpy
    Found existing installation: numpy 1.21.3
    Uninstalling numpy-1.21.3:
      Successfully uninstalled numpy-1.21.3
  Attempting uninstall: opencv-python
    Found existing installation: opencv-python 4.5.3.56
    Uninstalling opencv-python-4.5.3.56:
      Successfully uninstalled opencv-python-4.5.3.56
Successfully installed numpy-1.21.3 opencv-python-4.5.4.58
(venv) os@17:40:03> python testimshow.py 
Segmentation fault (core dumped)

Some extra info from gdb

(venv) os@17:40:05> gdb --args python testimshow.py 
GNU gdb (Ubuntu 10.1-2ubuntu2) 10.1.90.20210411-git
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from python...
(No debugging symbols found in python)
(gdb) r
Starting program: /home/os/Downloads/foo/venv/bin/python testimshow.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff3c96640 (LWP 15359)]
[New Thread 0x7ffff1495640 (LWP 15360)]
[New Thread 0x7fffeec94640 (LWP 15361)]
[New Thread 0x7fffec493640 (LWP 15362)]
[New Thread 0x7fffe9c92640 (LWP 15363)]
[New Thread 0x7fffe9491640 (LWP 15364)]
[New Thread 0x7fffe4c90640 (LWP 15365)]
[New Thread 0x7fffe248f640 (LWP 15366)]
[New Thread 0x7fffdfc8e640 (LWP 15367)]
[New Thread 0x7fffdd48d640 (LWP 15368)]
[New Thread 0x7fffdac8c640 (LWP 15369)]
[New Thread 0x7fffd848b640 (LWP 15370)]
[New Thread 0x7fffd5c8a640 (LWP 15371)]
[New Thread 0x7fffd3489640 (LWP 15372)]
[New Thread 0x7fffd0c88640 (LWP 15373)]

Thread 1 "python" received signal SIGSEGV, Segmentation fault.
0x00007fffbed45e05 in _xcb_in_expect_reply ()
   from /home/os/Downloads/foo/venv/lib/python3.9/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libxcb-65da195c.so.1.1.0
(gdb) bt
#0  0x00007fffbed45e05 in _xcb_in_expect_reply ()
   from /home/os/Downloads/foo/venv/lib/python3.9/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libxcb-65da195c.so.1.1.0
#1  0x00007fffbed44e94 in xcb_send_request_with_fds64 ()
   from /home/os/Downloads/foo/venv/lib/python3.9/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libxcb-65da195c.so.1.1.0
#2  0x00007fffbed44f69 in xcb_send_request ()
   from /home/os/Downloads/foo/venv/lib/python3.9/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libxcb-65da195c.so.1.1.0
#3  0x00007fffbed4af3f in xcb_intern_atom ()
   from /home/os/Downloads/foo/venv/lib/python3.9/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libxcb-65da195c.so.1.1.0
#4  0x00007fffc0b42ce4 in ?? ()
   from /home/os/Downloads/foo/venv/lib/python3.9/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libQt5XcbQpa-ca221f44.so.5.15.0
#5  0x00007fffc0b36ad3 in QtOpenCVPython::QXcbBasicConnection::QXcbBasicConnection(char const*) ()
   from /home/os/Downloads/foo/venv/lib/python3.9/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libQt5XcbQpa-ca221f44.so.5.15.0
#6  0x00007fffc0b14f22 in QtOpenCVPython::QXcbConnection::QXcbConnection(QtOpenCVPython::QXcbNativeInterface*, bool, unsigned int, char const*) ()
   from /home/os/Downloads/foo/venv/lib/python3.9/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libQt5XcbQpa-ca221f44.so.5.15.0
--Type <RET> for more, q to quit, c to continue without paging--c
#7  0x00007fffc0b17b47 in QtOpenCVPython::QXcbIntegration::QXcbIntegration(QtOpenCVPython::QStringList const&, int&, char**) () from /home/os/Downloads/foo/venv/lib/python3.9/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libQt5XcbQpa-ca221f44.so.5.15.0
#8  0x00007fffcd09543f in ?? () from /home/os/Downloads/foo/venv/lib/python3.9/site-packages/cv2/qt/plugins/platforms/libqxcb.so
#9  0x00007fffc55c0a6c in QtOpenCVPython::QGuiApplicationPrivate::createPlatformIntegration() () from /home/os/Downloads/foo/venv/lib/python3.9/site-packages/cv2/../opencv_python.libs/libQt5Gui-ba0a2070.so.5.15.0
#10 0x00007fffc55c2010 in QtOpenCVPython::QGuiApplicationPrivate::createEventDispatcher() () from /home/os/Downloads/foo/venv/lib/python3.9/site-packages/cv2/../opencv_python.libs/libQt5Gui-ba0a2070.so.5.15.0
#11 0x00007fffc4fcd2f6 in QtOpenCVPython::QCoreApplicationPrivate::init() () from /home/os/Downloads/foo/venv/lib/python3.9/site-packages/cv2/../opencv_python.libs/libQt5Core-39545cc7.so.5.15.0
#12 0x00007fffc55c4a3b in QtOpenCVPython::QGuiApplicationPrivate::init() () from /home/os/Downloads/foo/venv/lib/python3.9/site-packages/cv2/../opencv_python.libs/libQt5Gui-ba0a2070.so.5.15.0
#13 0x00007fffc5f13979 in QtOpenCVPython::QApplicationPrivate::init() () from /home/os/Downloads/foo/venv/lib/python3.9/site-packages/cv2/../opencv_python.libs/libQt5Widgets-e69d94fb.so.5.15.0
#14 0x00007fffc95e5f38 in ?? () from /home/os/Downloads/foo/venv/lib/python3.9/site-packages/cv2/cv2.cpython-39-x86_64-linux-gnu.so
#15 0x00007fffc95f1e3d in ?? () from /home/os/Downloads/foo/venv/lib/python3.9/site-packages/cv2/cv2.cpython-39-x86_64-linux-gnu.so
#16 0x00007fffc95e033c in ?? () from /home/os/Downloads/foo/venv/lib/python3.9/site-packages/cv2/cv2.cpython-39-x86_64-linux-gnu.so
#17 0x00007fffc88530a3 in ?? () from /home/os/Downloads/foo/venv/lib/python3.9/site-packages/cv2/cv2.cpython-39-x86_64-linux-gnu.so
#18 0x000000000054350c in ?? ()
#19 0x0000000000521d6b in _PyObject_MakeTpCall ()
#20 0x000000000051b9f8 in _PyEval_EvalFrameDefault ()
#21 0x0000000000514a75 in ?? ()
#22 0x000000000051480b in _PyEval_EvalCodeWithName ()
#23 0x00000000005fb257 in PyEval_EvalCode ()
#24 0x00000000006205fb in ?? ()
#25 0x000000000061b724 in ?? ()
#26 0x000000000061fb2d in ?? ()
#27 0x000000000061f63a in PyRun_SimpleFileExFlags ()
#28 0x0000000000613527 in Py_RunMain ()
#29 0x00000000005ef7fd in Py_BytesMain ()
#30 0x00007ffff7c19565 in __libc_start_main (main=0x5ef7c0, argc=2, argv=0x7fffffffdf18, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffdf08) at ../csu/libc-start.c:332
#31 0x00000000005ef6fe in _start ()

Previous version, which worked fine

(venv) os@17:38:52> pip install --force-reinstall opencv-python==4.5.3.56
Collecting opencv-python==4.5.3.56
  Using cached opencv_python-4.5.3.56-cp39-cp39-manylinux2014_x86_64.whl (49.9 MB)
Collecting numpy>=1.19.3
  Using cached numpy-1.21.3-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.7 MB)
Installing collected packages: numpy, opencv-python
  Attempting uninstall: numpy
    Found existing installation: numpy 1.21.3
    Uninstalling numpy-1.21.3:
      Successfully uninstalled numpy-1.21.3
  Attempting uninstall: opencv-python
    Found existing installation: opencv-python 4.5.3.56
    Uninstalling opencv-python-4.5.3.56:
      Successfully uninstalled opencv-python-4.5.3.56
Successfully installed numpy-1.21.3 opencv-python-4.5.3.56
(venv) os@17:39:31> pip install --force-reinstall opencv-python==4.5.3.56
Collecting opencv-python==4.5.3.56
  Using cached opencv_python-4.5.3.56-cp39-cp39-manylinux2014_x86_64.whl (49.9 MB)
Collecting numpy>=1.19.3
  Using cached numpy-1.21.3-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.7 MB)
Installing collected packages: numpy, opencv-python
  Attempting uninstall: numpy
    Found existing installation: numpy 1.21.3
    Uninstalling numpy-1.21.3:
      Successfully uninstalled numpy-1.21.3
  Attempting uninstall: opencv-python
    Found existing installation: opencv-python 4.5.3.56
    Uninstalling opencv-python-4.5.3.56:
      Successfully uninstalled opencv-python-4.5.3.56
Successfully installed numpy-1.21.3 opencv-python-4.5.3.56
(venv) os@17:39:47> python testimshow.py 

(displayed the image)

EDIT: I also tried installing in a clean virtualenv, as well as turning my computer off and then on again

@oseiskar oseiskar changed the title imshow segfaults in 4.5.3.56 on Ubuntu 21.04 (x86_64, Python 3.9) imshow segfaults in 4.5.4.58 on Ubuntu 21.04 (x86_64, Python 3.9) Oct 22, 2021
@SzabolcsGergely
Copy link

SzabolcsGergely commented Oct 22, 2021

+1
Have the same issue.
Works w/ python 3.6/7/8/10, only .9 has this issue.
Building python wheel from sources solves the issue.

More simple test to reproduce is:

python3.9 -c "import cv2; import numpy as np; img = np.zeros((100,100,3), dtype=np.uint8); cv2.imshow('test', img); cv2.waitKey(0)"

Other than that stack trace is the same.
Ubuntu 21.04

@skvark
Copy link
Member

skvark commented Oct 22, 2021

This is regression, somehow libcxb got embedded to the wheels while it should not be there (I spent quite a lot of time debugging this issue last year): https://github.com/opencv/opencv-python/blob/master/patch_auditwheel_whitelist.py

@skvark skvark added the bug label Oct 22, 2021
@SzabolcsGergely
Copy link

This is regression, somehow libcxb got embedded to the wheels while it should not be there (I spent quite a lot of time debugging this issue last year): https://github.com/opencv/opencv-python/blob/master/patch_auditwheel_whitelist.py

I think it's related to this commit, the change to a different docker image.

@skvark
Copy link
Member

skvark commented Oct 22, 2021

Yeah, the lines related to the patch_auditwheel_whitelist.py calls are not probably working as intended, the calls are most likely using the wrong interpreter.

See: pypa/manylinux@cb20b86#diff-6e80fedc6095017a37ae0db6fbc71b259e15e5972bb8aa810877344dd666b79b

We need to patch the py39 auditwheel which is used as "runtime" auditwheel in the manylinux images. Previously that was py37. The code introduced here will not work as intended because it patches wrong auditwheel instances.

@asmorkalov asmorkalov self-assigned this Oct 25, 2021
@dodobyte
Copy link

I also have the issue with cv2.namedWindow. Also can confirm that it works with python 3.8.

@eddie-kr
Copy link

Same issue here.
No updates yet?

@egeakman
Copy link

Same issue. Had to downgrade to the previous version.

@asenyaev
Copy link
Contributor

asenyaev commented Nov 2, 2021

I tried to reproduce this issue with the latest release of opencv-python and python3.9 on two devices with a clean environment and there are no segfaults, but I use Ubuntu 18.04. Does anyone has the issue on Ubuntu 18.04?

@asenyaev
Copy link
Contributor

asenyaev commented Nov 2, 2021

@skvark, when I updated docker images with the latest manylinux base images, I've faced a problem - there is auditwheel with 5.0.0 version and it can't repair properly wheels in case of libs. That's why I added lines to downgrade to 3.2.0 hardly for each python version as a hotfix.

One more thing is /opt/_internal/tools is a wrong path to TOOLS_PATH variable by default, it should be like this /opt/_internal/pipx/venvs/auditwheel, because there is no auditwheel in the first path.

In addition, auditwheel 5.0.0 has more platforms in manylinux-policy.json, and need to add each whitelisted lib for each platform, otherwise it throws errors. Currently, I'm trying to move to auditwheel 5.0.0 and update a patch.

@skvark
Copy link
Member

skvark commented Nov 2, 2021

@skvark, when I updated docker images with the latest manylinux base images, I've faced a problem - there is auditwheel with 5.0.0 version and it can't repair properly wheels in case of libs. That's why I added lines to downgrade to 3.2.0 hardly for each python version as a hotfix.

One more thing is /opt/_internal/tools is a wrong path to TOOLS_PATH variable by default, it should be like this /opt/_internal/pipx/venvs/auditwheel, because there is no auditwheel in the first path.

In addition, auditwheel 5.0.0 has more platforms in manylinux-policy.json, and need to add each whitelisted lib for each platform, otherwise it throws errors. Currently, I'm trying to move to auditwheel 5.0.0 and update a patch.

Yeah, it seems that auditwheel and the manylinux images have changed more than I thought. Previously it was just libxcb which caused errors after the repair process in Qt-enabled wheels.

@Andriamanitra
Copy link

I am also experiencing this issue in opencv-python version 4.5.4.58 (Python version 3.9.7, on Manjaro Linux). Executing the line cv2.imshow("image", img) causes the following error message:

fish: Job 1, 'python' terminated by signal SIGSEGV (Address boundary error)

Downgrading to a previous version of opencv fixes the issue:
pip install opencv-python==4.5.3.56

@HMaker
Copy link

HMaker commented Nov 9, 2021

I am also experiencing this same issue with opencv 4.5.4.58, Python 3.9.7 and Ubuntu 20.04.

@asmorkalov
Copy link
Collaborator

@HMaker The issue has been fixed on infrastructure side. We are working on bug fix release now. Please downgrade OpenCV to previous release, if you need urgent fix.

@asmorkalov asmorkalov assigned asenyaev and unassigned asmorkalov Nov 10, 2021
@boris-gu boris-gu mentioned this issue Nov 14, 2021
4 tasks
@Adian-kids
Copy link

Same issue on Arch Linux,can i use a low version opencv to resove it?

@egeakman
Copy link

Same issue on Arch Linux,can i use a low version opencv to resove it?

@Adian-kids yessir

@EliuTimana
Copy link

Same problem here, but it only fails when OpenCV is installed from pip, using python3-opencv package works.

Python 3.9.7
pip 21.3.1 from /home/eliu/.local/lib/python3.9/site-packages/pip (python 3.9)
Linux IdeaPad-Y500 5.13.0-21-generic #21-Ubuntu SMP Tue Oct 19 08:59:28 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

@SzabolcsGergely
Copy link

This issue is fixed in latest 4.5.4.60.

@asmorkalov
Copy link
Collaborator

Thanks a lot for rapid feedback!

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

No branches or pull requests