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

[bug]OpenCV crashes the program on Linux #16840

Open
Marijameme opened this issue Aug 18, 2024 · 5 comments
Open

[bug]OpenCV crashes the program on Linux #16840

Marijameme opened this issue Aug 18, 2024 · 5 comments
Assignees

Comments

@Marijameme
Copy link

Marijameme commented Aug 18, 2024

Describe the bug

Hi there,
I'm using opencv library in my project, and I installed it using conan but it started crashing with the error:
Gtk:ERROR:../../../../gtk/gtkiconhelper.c:494:ensure_surface_for_gicon: assertion failed (error == NULL): Failed to load /usr/share/icons/Yaru/16x16/status/image-missing.png: Fatal error reading PNG image file: Invalid IHDR data (gdk-pixbuf-error-quark, 0) Bail out! Gtk:ERROR:../../../../gtk/gtkiconhelper.c:494:ensure_surface_for_gicon: assertion failed (error == NULL): Failed to load /usr/share/icons/Yaru/16x16/status/image-missing.png: Fatal error reading PNG image file: Invalid IHDR data (gdk-pixbuf-error-quark, 0) Aborted
Then I installed the library manually and the program is running perfectly fine. Before this, the program would crash just moments after being started, after almost zero interaction with the program. The funny thing is that it doesn't crash always, sometimes (although rarely) it works fine and the library behaves the way it is expected. I didn't do anything fancy with my CMake in order to include the library, just the following

find_package(OpenCV REQUIRED)   
include_directories( ${OpenCV_INCLUDE_DIRS} )    
target_link_libraries(${PROJECT_NAME} PUBLIC ${OpenCV_LIBS})

Environment details

  • OS: Ubuntu 20.04
  • conan: 2.5.0
  • compiler: gcc: 17 (but I tried with 11 too)
  • conan profile:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=11
os=Linux

[conf]
tools.system.package_manager:mode=install
tools.system.package_manager:sudo=True

@valgur
Copy link
Contributor

valgur commented Aug 18, 2024

It looks like the error occurs in GTK and is only tangentially related to OpenCV. I suspect the issue is caused by gtk/system being used and it transitively linking against libpng or something similar.

The only real fix for that would be to use a proper Conan version of GTK, but it's yet to be migrated. Mostly due to a bunch of trivial version conflicts blocking the build:

You can give the updated recipe in that PR or in my personal fork (https://github.com/valgur/conan-center-index) a try.

@memsharded
Copy link
Member

Hi @Marijameme

Quick question: did you use pre-compiled binaries from ConanCenter, or are you building them from source?
If you installed pre-compiled binaries from ConanCenter, can you please try to build from source forcing it with --build=* and try again?

Also, using:

include_directories( ${OpenCV_INCLUDE_DIRS} )    
target_link_libraries(${PROJECT_NAME} PUBLIC ${OpenCV_LIBS})

Is not recommended in the general case. CMake recommends using targets, so please drop the include_directories() and use the target in target_link_libraries(... PUBLIC opencv_xxxx). Targets might have other extra information, like preprocessor definition, compiler flags, etc.

@Marijameme
Copy link
Author

Hi @memsharded, i took your suggestion and built the library from source and made changes to my CMake file but the problem is still there, only less frequent. Also, when it runs I get a warning:
Gtk-WARNING **: 18:41:12.072: Could not load a pixbuf from icon theme. This may indicate that pixbuf loaders or the mime database could not be found.

@czoido
Copy link
Contributor

czoido commented Aug 20, 2024

Hi @Marijameme,
Which OpenCV version are you using? If your are using some version<4.7.0 could you please check if this issue still happens for a newer version? Like: 4.10.0, 4.9.0 or 4.8.1?
Thanks a lot.

@Marijameme
Copy link
Author

I tried with 4.10.0 originally, and then with 4.9.0 and 4.5.5, everything was the same.

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

No branches or pull requests

4 participants