gmic_gimp_qt: fatal error: Segmentation fault

Hi,
I’m on Arch Linux and just updated my machine tonight for first time in a month because of the nVidia driver debacle that was going on. When I went to try use gmic plugin, I was faced with this and other errors.

(gmic_gimp_qt:38551): Gtk-WARNING **: 20:10:25.268: Theme parsing error: gtk.css:4:1: '/*' in comment block
    /usr/lib/gimp/2.0/plug-ins/gmic_gimp_qt: fatal error: Segmentation fault
    Terminating plug-in: '/usr/lib/gimp/2.0/plug-ins/gmic_gimp_qt'
    GIMP-Error: Plug-in crashed: "gmic_gimp_qt"
    (/usr/lib/gimp/2.0/plug-ins/gmic_gimp_qt)

The dying plug-in may have messed up GIMP's internal state. You may want to save your images and restart GIMP to be on the safe side.

I’ve tried the following things.

  • Removed my .config/gmic folder
  • Downgraded gimp to 2.10.18-8
  • Downgraded gmic to 2.9.2-3

Here is the gmic_qt_log:

[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./gui_filter_sources/ Skip argument '1,1'.
[gmic]-0./gui_filter_sources/*if/ Start 'if...endif' block -> condition '1' holds.
[gmic]-0./gui_filter_sources/*if/ Set local variable 'local=/home/akovia/.config/gmic/update293.gmic'.
[gmic]-0./gui_filter_sources/*if/*if/ Start 'if...endif' block -> condition 'isfile(['/home/akovia/.config/gmic/update293.gmic'])' does not hold.
[gmic]-0./gui_filter_sources/*if/*if/ End 'if...endif' block.
[gmic]-0./gui_filter_sources/*if/ End 'if...endif' block.
[gmic]-0./gui_filter_sources/*if/ Start 'if...endif' block -> condition 'u>0.95' does not hold.
[gmic]-0./gui_filter_sources/*if/ End 'if...endif' block.
[gmic]-0./gui_filter_sources/ Input image at position 0, with values (104,116,116,112,115,58,47,47,103,109,(...)116,101,50,57,51,46,103,109,105,99,1) (1 image 31x1x1x1).
[gmic]-1./gui_filter_sources/*local/ Start 'local...endlocal' block, with selected image [].
[gmic]-0./gui_filter_sources/*local/ Input file '_gui_filter_sources' at position 0
[gmic]-0./gui_filter_sources/*local/ e[0;31;59me[1m*** Error *** Unknown command or filename '_gui_filter_sources'; did you mean 'gui_filter_sources'?e[0;0;0m
[gmic]-1./gui_filter_sources/*local/ Reach 'onfail' block.
[gmic]-0./gui_filter_sources/*local/ Remove image [] (0 images left).
[gmic]-0./gui_filter_sources/*local/ End 'local...endlocal' block.
[gmic]-1./gui_filter_sources/*local/ Start 'local...endlocal' block, with selected image [].
[gmic]-0./gui_filter_sources/*local/ e[0;31;59me[1m*** Error *** Unknown filename '/home/akovia/.config/gmic/gui_filter_sources'.e[0;0;0m
[gmic]-1./gui_filter_sources/*local/ Reach 'onfail' block.
[gmic]-0./gui_filter_sources/*local/ End 'local...endlocal' block. (1 image 18x1x1x1).

$gmic image.jpg
Launches fine, but I have no idea how to use it in that state. I see the image and cursor crosshairs, but no controls or options.

I’m gutted that not even downgrading works.

Thanks,
Akovia

Interesting.
Do you think you’d be able to ‘trace’ the bug more precisely, maybe by recompiling the plug-in in ‘Debug’ mode ?
Without more info, it’s a bit hard to figure out what is happening.

Are there instructions anywhere on how to do this?

I can’t seem to find any good instructions anywhere. Do I have to build both gmic and the gimp plugin separately and both in debug mode?

Do I build the QT version? When installing from the Arch aur, it requires QT, so is this the correct source to build from?

I tried following the build instructions there and it seemed to compile ok, but didn’t seem to install. I tried make install, but that didn’t help.

I’m willing to try anything, but need at least a little help. I am a power user and I am now dead in the water.

Thanks

Here is my suggestion.

  • To trace this kind of error, it is interesting to compile it with g++, with the flag -fsanitize=address, as it somehow embeds a memory debugger directly in the compiled binary.
  • To make it simpler to test, it’s probably also better not to run the plug-in, but the stand-alone G’MIC-Qt application from the console.
  • If there is one error somewhere in the code, then G’MIC-Qt will stop and an error message will appear in the console.

Here are the compilation steps I’ve used:

  • From the G’MIC-Qt sources, in folder gmic-qt, I first edit the gmic_qt.pro file, replacing lines 448 and 449 by:
    QMAKE_CXXFLAGS_DEBUG += -fsanitize=address -g
    QMAKE_LFLAGS_DEBUG += -fsanitize=address -g

(i.e., uncomment and add the -g flag).
Then I compile the stand-alone application in Debug mode:

$ qmake HOST=none CONFIG+=debug
(...)
$ make

It may happen the compiler stops during the link phase with an error about a lot of asan-related functions not found. I just copy/paste the latest g++ command that failed and add -lasan at the end. For me this looks like this (I’m on Ubuntu 19.04) :

g++ -c -pipe -g -fopenmp -Dcimg_verbosity=3 -fsanitize=address -g -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -Dcimg_use_cpp11=1 -Dcimg_use_fftw3 -Dcimg_use_zlib -Dgmic_build -Dcimg_use_abort -Dgmic_is_parallel -Dcimg_use_curl -Dcimg_use_png -Dcimg_appname=\"gmic\" -Dgmic_prerelease=\"201123\" -Dcimg_display=1 -D_IS_LINUX_ -DGMIC_HOST=standalone -Dcimg_use_openmp -Dgmic_gui -Dgmic_build -Dgmic_is_parallel -Dcimg_use_abort -Dcimg_use_vt100 -D_GMIC_QT_DEBUG_ -D_IS_UNIX_ -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I. -Isrc -I../gmic/src -isystem /usr/include/libpng16 -isystem /usr/include/x86_64-linux-gnu -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtNetwork -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I.moc -isystem /usr/include/libdrm -I.ui -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o .obj/moc_ProgressInfoWindow.o .moc/moc_ProgressInfoWindow.cpp
g++ -fopenmp -fsanitize=address -g -o gmic_qt .obj/host_none.o .obj/ImageDialog.o .obj/ClickableLabel.o .obj/Common.o .obj/OverrideCursor.o .obj/DialogSettings.o .obj/AbstractParameter.o .obj/BoolParameter.o .obj/ButtonParameter.o .obj/ChoiceParameter.o .obj/ColorParameter.o .obj/ConstParameter.o .obj/CustomDoubleSpinBox.o .obj/FileParameter.o .obj/FilterParametersWidget.o .obj/FloatParameter.o .obj/FolderParameter.o .obj/IntParameter.o .obj/LinkParameter.o .obj/MultilineTextParameterWidget.o .obj/NoteParameter.o .obj/PointParameter.o .obj/SeparatorParameter.o .obj/TextParameter.o .obj/FiltersModel.o .obj/FiltersModelReader.o .obj/FiltersPresenter.o .obj/FiltersView.o .obj/TreeView.o .obj/FiltersVisibilityMap.o .obj/CroppedImageListProxy.o .obj/CroppedActiveLayerProxy.o .obj/FilterSyncRunner.o .obj/FilterThread.o .obj/gmic_qt.o .obj/FilterTextTranslator.o .obj/Globals.o .obj/GmicStdlib.o .obj/GmicProcessor.o .obj/HeadlessProcessor.o .obj/HtmlTranslator.o .obj/IconLoader.o .obj/ImageConverter.o .obj/ImageTools.o .obj/InputOutputState.o .obj/KeypointList.o .obj/LayersExtentProxy.o .obj/LanguageSettings.o .obj/Logger.o .obj/MainWindow.o .obj/ParametersCache.o .obj/TimeLogger.o .obj/Updater.o .obj/Utils.o .obj/FilterTreeItem.o .obj/FilterTreeFolder.o .obj/FavesModel.o .obj/FavesModelReader.o .obj/FilterTreeAbstractItem.o .obj/FilterTreeItemDelegate.o .obj/FavesModelWriter.o .obj/PreviewWidget.o .obj/ProgressInfoWidget.o .obj/InOutPanel.o .obj/ZoomLevelSelector.o .obj/SearchFieldWidget.o .obj/LanguageSelectionWidget.o .obj/ProgressInfoWindow.o .obj/gmic.o .obj/qrc_gmic_qt.o .obj/qrc_translations.o .obj/qrc_standalone.o .obj/moc_ImageDialog.o .obj/moc_ClickableLabel.o .obj/moc_DialogSettings.o .obj/moc_AbstractParameter.o .obj/moc_BoolParameter.o .obj/moc_ButtonParameter.o .obj/moc_ChoiceParameter.o .obj/moc_ColorParameter.o .obj/moc_ConstParameter.o .obj/moc_CustomDoubleSpinBox.o .obj/moc_FileParameter.o .obj/moc_FilterParametersWidget.o .obj/moc_FloatParameter.o .obj/moc_FolderParameter.o .obj/moc_IntParameter.o .obj/moc_LinkParameter.o .obj/moc_MultilineTextParameterWidget.o .obj/moc_NoteParameter.o .obj/moc_PointParameter.o .obj/moc_SeparatorParameter.o .obj/moc_TextParameter.o .obj/moc_FiltersPresenter.o .obj/moc_FiltersView.o .obj/moc_TreeView.o .obj/moc_FilterSyncRunner.o .obj/moc_FilterThread.o .obj/moc_FilterTextTranslator.o .obj/moc_GmicProcessor.o .obj/moc_HeadlessProcessor.o .obj/moc_MainWindow.o .obj/moc_Updater.o .obj/moc_PreviewWidget.o .obj/moc_ProgressInfoWidget.o .obj/moc_InOutPanel.o .obj/moc_ZoomLevelSelector.o .obj/moc_SearchFieldWidget.o .obj/moc_LanguageSelectionWidget.o .obj/moc_ProgressInfoWindow.o   -lfftw3_threads -lfftw3 -lpng16 -lz -lcurl -lX11 /usr/lib/x86_64-linux-gnu/libQt5Widgets.so /usr/lib/x86_64-linux-gnu/libQt5Gui.so /usr/lib/x86_64-linux-gnu/libQt5Network.so /usr/lib/x86_64-linux-gnu/libQt5Core.so /usr/lib/x86_64-linux-gnu/libGL.so -lpthread -lasan

(For an unknown reason, I had to do this “manually” because if I add the -lasan flag in the gmic_qt.pro file, it doesn’t succeed at all, because -lasan is put on the beginning of the command, while it has to appear apparently at the end).

Then, you can run the gmic_qt executable, and play with it until a crash:

$ ./gmic_qt image.jpg

So far, I didn’t succeed in having a crash here, but I hope you’ll be able to reproduce your bug this way, and tell us what is going on :slight_smile:

Here’s what happened…

$ ./gmic_qt image.jpg 

(gmic_qt:362598): Gtk-WARNING **: 12:55:08.025: Theme parsing error: gtk.css:4:1: '/*' in comment block
AddressSanitizer:DEADLYSIGNAL
=================================================================
==362598==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f382429ea88 bp 0x7fff539549f0 sp 0x7fff53954170 T0)
==362598==The signal is caused by a READ memory access.
==362598==Hint: address points to the zero page.
    #0 0x7f382429ea88 in __interceptor_strcmp /build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:442
    #1 0x564f6353dd79 in gmic& gmic::_run<float>(cimg_library::CImgList<char> const&, unsigned int&, cimg_library::CImgList<float>&, cimg_library::CImgList<char>&, cimg_library::CImgList<float>&, cimg_library::CImgList<char>&, unsigned int const*, bool*, char const*, cimg_library::CImg<unsigned int> const*) ../src/gmic.cpp:15010
    #2 0x564f6342fb65 in gmic& gmic::_run<float>(cimg_library::CImgList<char> const&, cimg_library::CImgList<float>&, cimg_library::CImgList<char>&, float*, bool*) ../src/gmic.cpp:4973
    #3 0x564f634188b3 in void gmic::_gmic<float>(char const*, cimg_library::CImgList<float>&, cimg_library::CImgList<char>&, char const*, bool, float*, bool*) ../src/gmic.cpp:4077
    #4 0x564f6340e93c in gmic::gmic<float>(char const*, cimg_library::CImgList<float>&, cimg_library::CImgList<char>&, char const*, bool, float*, bool*) ../src/gmic.cpp:3973
    #5 0x564f6336005b in Updater::updateSources(bool) src/Updater.cpp:69
    #6 0x564f633607f0 in Updater::startUpdate(int, int, bool) src/Updater.cpp:102
    #7 0x564f6333de42 in MainWindow::showEvent(QShowEvent*) src/MainWindow.cpp:1113
    #8 0x7f382389eb0d in QWidget::event(QEvent*) (/usr/lib/libQt5Widgets.so.5+0x19bb0d)
    #9 0x7f382385d751 in QApplicationPrivate::notify_helper(QObject*, QEvent*) (/usr/lib/libQt5Widgets.so.5+0x15a751)
    #10 0x7f3822c13a79 in QCoreApplication::notifyInternal2(QObject*, QEvent*) (/usr/lib/libQt5Core.so.5+0x2b5a79)
    #11 0x7f382389b337 in QWidgetPrivate::show_helper() (/usr/lib/libQt5Widgets.so.5+0x198337)
    #12 0x7f382389e64c in QWidgetPrivate::setVisible(bool) (/usr/lib/libQt5Widgets.so.5+0x19b64c)
    #13 0x564f632cded8 in launchPlugin() src/gmic_qt.cpp:130
    #14 0x564f6316a415 in main src/Host/None/host_none.cpp:232
    #15 0x7f3822395151 in __libc_start_main (/usr/lib/libc.so.6+0x28151)
    #16 0x564f63166dcd in _start (/home/akovia/build/gmic_2.9.3/gmic-2.9.3/gmic-qt/gmic_qt+0x231dcd)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:442 in __interceptor_strcmp
==362598==ABORTING
1 Like

That’s interesting, thanks. Will check.

Update : I’ve currently compiled G’MIC with the address sanitizer and I get indeed a few issues.
I’ll try to fix those ASAP and make you know when it’s ready.
This will probably lead to a 2.9.4 release…

Thanks for your report!

1 Like

I’ve made two fixes related to possible wron memory access.
Would you like to test on your machine ?
Basically, you have to modify file gmic.cpp, with the following commits:

and

That’s minor modifications that you can apply on the sources, then you have to recompile everything, and test once again.
Thanks for your help !

I’d love to try it but I’m not finding gmic.cpp in my sources.

I went to the gmic-master source tree in the git links you sent and modified the code as suggested, but then the commands you gave to build it do not work.

Sorry but it seems I need some hand-holding, as I don’t understand how to build it.

I’ll prepare an up-to-date pre-release archive and post it in a few minutes (half an hour).
It will be easier to make the test. I’ll let you know when it’s ready!

Thank you!

Here is the link : https://gmic.eu/files/prerelease/gmic_2.9.4_pre201123.tar.gz

Just untar.gz it, go the gmic/gmic-qt then qmake and make, and it should compile the plug-in for GIMP.

EDIT: I’m 90% sure the problem will be fixed :slight_smile:

Thanks.

I built and installed as instructed, but gimp does not show the plugin is installed. Do I need to manually copy files to the gimp folder?

Yes, you have to copy gmic_gimp_qt in the GIMP plug-in folder, indeed.

Well I figured this must be the case and copied gmic_gimp_qt to my plugin folder and gave it a go.

gmic_gimp_qt:419520): Gtk-WARNING **: 15:35:09.070: Theme parsing error: gtk.css:4:1: '/*' in comment block
/home/akovia/.config/GIMP/2.10/plug-ins/gmic_gimp_qt: fatal error: Segmentation fault
Terminating plug-in: '/home/akovia/.config/GIMP/2.10/plug-ins/gmic_gimp_qt'
GIMP-Error: Plug-in crashed: "gmic_gimp_qt"
(/home/akovia/.config/GIMP/2.10/plug-ins/gmic_gimp_qt)

The dying plug-in may have messed up GIMP's internal state. You may want to save your images and restart GIMP to be on the safe side.

Haa bad news.
So, could you do the same procedure as before, compiling it with the fsanitize=address enabled ?
Also, please check that GIMP actually takes the latest binary of the plug-in, sometimes there are duplicates and it’s not always easy to find which binary it loads.

I’ve another idea, anyway.
Will check.

I think I get it now.
Could you please replace the gmic.cpp file in the latest .tar.gz file you downloaded, by this version: https://raw.githubusercontent.com/dtschump/gmic/develop/src/gmic.cpp

I’m confident this time :slight_smile:

I think I was chasing my tail for a while. Should I have tried to make clean between builds?

Anyway, I just deleted the entire build directory and tried again with the new gmic.cpp. Here’s what happened.

(gmic_gimp_qt~:442422): Gtk-WARNING **: 16:32:19.546: Theme parsing error: gtk.css:4:1: '/*' in comment block
/home/akovia/.config/GIMP/2.10/plug-ins/gmic_gimp_qt~: fatal error: Segmentation fault
Terminating plug-in: '/home/akovia/.config/GIMP/2.10/plug-ins/gmic_gimp_qt~'
GIMP-Error: Plug-in crashed: "gmic_gimp_qt~"
(/home/akovia/.config/GIMP/2.10/plug-ins/gmic_gimp_qt~)

The dying plug-in may have messed up GIMP's internal state. You may want to save your images and restart GIMP to be on the safe side.

I’m pretty sure I’ve fixed the first issue you got.
It was related to a null pointer, used for a string comparison.

Maybe there are another problem going on.
Again, if you succeed in compiling the stand-alone G’MIC-Qt application, with fsanitize=address enabled, and copy/paste the error log you get from the console, I’ll be able to better understand where the problem comes from, and hopefully fix it.
I’m still a bit surprised about the fact it doesn’t work, but of course, it’s hard to test on all different architectures and compiler versions, so these things may happen from time to time.