Bug 383339 - Gmic crash when applying any filter
Summary: Gmic crash when applying any filter
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: G'Mic for Krita (show other bugs)
Version: 3.2.0-beta.2
Platform: Microsoft Windows Microsoft Windows
: NOR crash
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-10 02:42 UTC by Marcos Ebrahim
Modified: 2017-08-26 17:50 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 3.2.0 rc.3


Attachments
attachment-16401-0.html (2.28 KB, text/html)
2017-08-12 07:41 UTC, Marcos Ebrahim
Details
gmic_Krita_close_Error.LOG (31.26 KB, application/octet-stream)
2017-08-12 08:11 UTC, Marcos Ebrahim
Details
gmic_Krita3.2.rc.3.1_crashNotclose_Error.LOG (46.81 KB, application/octet-stream)
2017-08-13 03:24 UTC, Marcos Ebrahim
Details
attachment-29144-0.html (1.77 KB, text/html)
2017-08-13 04:29 UTC, Marcos Ebrahim
Details
attachment-29473-0.html (3.97 KB, text/html)
2017-08-13 04:36 UTC, Marcos Ebrahim
Details
kritacrash.log (319.75 KB, application/octet-stream)
2017-08-13 08:03 UTC, Marcos Ebrahim
Details
gmic_Krita3.2.rc.3.1_crashNotclose_diff_mem_config_Error.LOG (125.20 KB, application/octet-stream)
2017-08-13 08:03 UTC, Marcos Ebrahim
Details
kritacrash.log (349.73 KB, application/octet-stream)
2017-08-13 18:32 UTC, Marcos Ebrahim
Details
gmic_Krita3.2.rc.3.2.LOG (134.17 KB, application/octet-stream)
2017-08-13 18:32 UTC, Marcos Ebrahim
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marcos Ebrahim 2017-08-10 02:42:20 UTC
when apply any g'mic filter gmic window clash by closing after hit ok or apply button this happen with all gmic filters with krita 3.2.0-rc.1 and gmic 2.0.3 

OS Information
  Build ABI: x86_64-little_endian-llp64
  Build CPU: x86_64
  CPU: x86_64
  Kernel Type: winnt
  Kernel Version: 10.0.15063
  Pretty Productname: Windows 10
  Product Type: windows
  Product Version: 10

OpenGL Info
  Vendor: ATI Technologies Inc.
  Renderer: AMD Radeon R9 200 Series
  Version: 3.0.13491 Compatibility Profile Context 22.19.662.4
  Shading language: 4.50
   Version: 3.0
     Supports deprecated functions: true

Thanks
Comment 1 Alvin Wong 2017-08-11 18:34:42 UTC
Just to clarify, do you mean the gmic-qt process crashes or Krita itself crashes? Or do you mean the gmic-qt plugin window simply closes without any messages?
If it's Krita which crashes, can you get a backtrace by following this? https://docs.krita.org/Dr._Mingw_debugger

If it's only the gmic-qt plugin, are you pressing Ok or Apply after waiting for the preview to show? Does the preview show properly? How long after you pressed the button does it crash?

Also, can you provide some information on the image you are using: What is the colour format and bit depth of the image?
Comment 2 Marcos Ebrahim 2017-08-12 05:25:16 UTC Comment hidden (obsolete)
Comment 3 Alvin Wong 2017-08-12 07:30:56 UTC Comment hidden (obsolete)
Comment 4 Marcos Ebrahim 2017-08-12 07:41:24 UTC
Created attachment 107221 [details]
attachment-16401-0.html

https://drive.google.com/file/d/0B7s2GTvkS2N_LVBndFQ4VzVjNUU/view?usp=sharing

Just copy the link and paste in your browser and it will work.if not I will
send you a Dropbox link.
Thanks

On Aug 12, 2017 9:31 AM, "Alvin Wong" <bugzilla_noreply@kde.org> wrote:

> https://bugs.kde.org/show_bug.cgi?id=383339
>
> Alvin Wong <alvinhochun@gmail.com> changed:
>
>            What    |Removed                     |Added
> ------------------------------------------------------------
> ----------------
>              Status|UNCONFIRMED                 |NEEDSINFO
>          Resolution|---                         |WAITINGFORINFO
>
> --- Comment #3 from Alvin Wong <alvinhochun@gmail.com> ---
> Hi Marcos, we cannot see any attachments from your reply. Please try to
> upload
> and share the file via Dropbox or Google Drive instead.
>
> (As a side note, I should point out that I am not KDE support, but a
> volunteer
> contributor working on Krita.)
>
> (In reply to Marcos Ebrahim from comment #2)
> > Hi Alvin,
> > I attached screen record for the problem. because of the recording
> program
> > you willnot notice this at first time I press ok key in gmic and second
> > time press apply .the two times with the same result .I do this on jpg
> > picture but I try this with many file with the same result you see in the
> > video.
> > let me know if you need additional info about this issues .
> > Thanks for KDE support.
> > Best Regards,
> > Marcos
>
> --
> You are receiving this mail because:
> You reported the bug.
Comment 5 Alvin Wong 2017-08-12 07:50:37 UTC Comment hidden (obsolete)
Comment 6 Marcos Ebrahim 2017-08-12 08:11:14 UTC
Created attachment 107222 [details]
gmic_Krita_close_Error.LOG

After I update gmic to new version .I got the same Error .this is the debug
report .
Thanks

On Sat, Aug 12, 2017 at 9:50 AM, Alvin Wong <bugzilla_noreply@kde.org>
wrote:

> https://bugs.kde.org/show_bug.cgi?id=383339
>
> --- Comment #5 from Alvin Wong <alvinhochun@gmail.com> ---
> Thanks for your information. There are two things I would like you to try:
>
> 1. Can you try updating the gmic-qt plugin? A new version was uploaded
> yesterday.
> 2. Can you please download DebugView
> (https://docs.microsoft.com/en-us/sysinternals/downloads/debugview) and
> open it
> before starting the gmic-qt plugin, and provide the captured logs after you
> tried applying a filter?
>
> --
> You are receiving this mail because:
> You reported the bug.
>
Comment 7 Halla Rempt 2017-08-12 16:40:11 UTC
Could you try with https://download.kde.org/unstable/krita/3.2.0-rc.3/ -- I've built the gmic_krita_qt executable against the same version of Qt as Krita. If this doesn't work, I'm going to begin to suspect antivirus or other security software...
Comment 8 Silvio Grosso 2017-08-12 22:10:26 UTC
Hello everyone,

Sorry to hijajack this bug report but I have tried to reproduce myself this bug on Windows 7 and Windows 10 (both 64 bit).

To do so I have downloaded the latest krita provided today by Boud. The one with G'mic with the same QT version of Krita (krita 3.2.0.rc3.1_x64_setup.exe).
On my two systems (W7 and W10) the G'mic plugin does not crash but it is acting extremely weird. In short it only sometimes "works".
The preview is always correct but the filter is not usually applied on my image (I have tried both to press "apply" or "Ok").
Once in a while it works though !
Usually, It looks like G'mic is unable to apply the filter on the whole image. 
I have tried different jpeg and png images and it looks like jpeg images are more prone to errors.
These same images work fine on Gimp 2.8.20 and G'mic 2.0.2 (qt version).

I have recorded a video to show these glitches (again, it is very difficult to reproduce these problems because the end result depends on the images I try...).

Here is a link for my video (Windows 7 - 64 bit):
https://www.dropbox.com/s/wlfxx5f0kuoer55/GMIC_KRITA_BUG.mp4?dl=0

Here is a jpeg image which gives plenty of problems with G'MIC and Krita:
https://www.dropbox.com/s/a0d46qbamc1e8hx/BIANCOSPINO_B-W.jpg?dl=0

Btw, the same problems occured with the Krita 3.2 release candidate (available 5 days ago to download). All g'mic filters worked on random on my images (but usually they were not applied to the image...)

Btw, there is another smal bug concerning the g'mic window preview. When you zoom-in and zoom-out everything works. But the reset button does not work at all (in essence, when the preview image is zoomed-in you are forced to zoom-out manually because the reset zoom button does not work)
Comment 9 Silvio Grosso 2017-08-12 22:39:49 UTC
Hello everyone,

Now I "finally" get a crash myself :-)
Windows 7 - 64 bit
Intel I7
Nvidia Geforce

With the jpeg image I have attached to Dropbox I can always make Krita - G'mic crash as soon as I click apply or Ok to the filter (e.g. black-white g'mic filter).
I don't know what occures with Dropbox but it looks like the jpeg image (biancospino_w-b) I have previously copied-pasted in Dropbox is much different when I *right-click* on it to download "as image" on my computer once again (to test it myself...). 
Its size is much smaller, 600kb the original jpeg vs 101 kb the downloaded from Dropbox,  and many exif metadata are lost in the process (copyright etc).

Here is the ouput captured with DebugView for this crash:
https://www.dropbox.com/s/m7wys0dewmc1wx4/gmic_crash.LOG?dl=0
Comment 10 Marcos Ebrahim 2017-08-13 03:24:33 UTC Comment hidden (obsolete)
Comment 11 Alvin Wong 2017-08-13 04:23:44 UTC Comment hidden (obsolete)
Comment 12 Marcos Ebrahim 2017-08-13 04:29:24 UTC Comment hidden (obsolete)
Comment 13 Alvin Wong 2017-08-13 04:31:06 UTC Comment hidden (obsolete)
Comment 14 Marcos Ebrahim 2017-08-13 04:36:19 UTC Comment hidden (obsolete)
Comment 15 Alvin Wong 2017-08-13 04:39:05 UTC Comment hidden (obsolete)
Comment 16 Alvin Wong 2017-08-13 06:09:14 UTC
Thanks, I am able to reproduce the crash with the file you attached.

I can try to dig deeper from here.


Thread 1 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 10908.0x435c]
0x000007fefd05586f in strcpy () from C:\Windows\system32\msvcrt.dll
(gdb) bt
#0  0x000007fefd05586f in strcpy () from C:\Windows\system32\msvcrt.dll
#1  0x00000000004c9e14 in gmic_qt_output_images(cimg_library::CImgList<float>&, cimg_library::CImgList<char> const&, GmicQt::OutputMode, char const*) ()
#2  0x000000000042126c in MainWindow::onApplyThreadFinished() ()
#3  0x00000000004cd755 in MainWindow::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) ()
#4  0x0000000068a2fc2c in QObject::event(QEvent*) () from F:\dev\krita\boud_builds\krita-3.2.0-rc.3.1-x64\bin\Qt5Core.dll
#5  0x000000000108da2c in QWidget::event(QEvent*) () from F:\dev\krita\boud_builds\krita-3.2.0-rc.3.1-x64\bin\Qt5Widgets.dll
#6  0x000000000104a33c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from F:\dev\krita\boud_builds\krita-3.2.0-rc.3.1-x64\bin\Qt5Widgets.dll
#7  0x000000000104f6a0 in QApplication::notify(QObject*, QEvent*) () from F:\dev\krita\boud_builds\krita-3.2.0-rc.3.1-x64\bin\Qt5Widgets.dll
#8  0x0000000068a0e9f2 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from F:\dev\krita\boud_builds\krita-3.2.0-rc.3.1-x64\bin\Qt5Core.dll
#9  0x0000000068a13300 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) ()
   from F:\dev\krita\boud_builds\krita-3.2.0-rc.3.1-x64\bin\Qt5Core.dll
#10 0x000000006a8eab1e in qwindows!qt_plugin_instance () from F:\dev\krita\boud_builds\krita-3.2.0-rc.3.1-x64\bin\platforms\qwindows.dll
#11 0x0000000068a5577a in QEventDispatcherWin32Private::sendTimerEvent(int) () from F:\dev\krita\boud_builds\krita-3.2.0-rc.3.1-x64\bin\Qt5Core.dll
#12 0x0000000076bd9bbd in USER32!TranslateMessageEx () from C:\Windows\system32\user32.dll
#13 0x0000000076bd98c2 in USER32!TranslateMessage () from C:\Windows\system32\user32.dll
#14 0x0000000068a54eb3 in QEventDispatcherWin32::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from F:\dev\krita\boud_builds\krita-3.2.0-rc.3.1-x64\bin\Qt5Core.dll
#15 0x000000006a8eab05 in qwindows!qt_plugin_instance () from F:\dev\krita\boud_builds\krita-3.2.0-rc.3.1-x64\bin\platforms\qwindows.dll
#16 0x0000000068a0dcca in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from F:\dev\krita\boud_builds\krita-3.2.0-rc.3.1-x64\bin\Qt5Core.dll
#17 0x0000000068a14927 in QCoreApplication::exec() () from F:\dev\krita\boud_builds\krita-3.2.0-rc.3.1-x64\bin\Qt5Core.dll
#18 0x000000000040460d in launchPlugin() ()
#19 0x00000000004caa44 in main ()


(In reply to Silvio Grosso from comment #9)
> Hello everyone,
> 
> Now I "finally" get a crash myself :-)
> Windows 7 - 64 bit
> Intel I7
> Nvidia Geforce
> 
> With the jpeg image I have attached to Dropbox I can always make Krita -
> G'mic crash as soon as I click apply or Ok to the filter (e.g. black-white
> g'mic filter).
> I don't know what occures with Dropbox but it looks like the jpeg image
> (biancospino_w-b) I have previously copied-pasted in Dropbox is much
> different when I *right-click* on it to download "as image" on my computer
> once again (to test it myself...). 
> Its size is much smaller, 600kb the original jpeg vs 101 kb the downloaded
> from Dropbox,  and many exif metadata are lost in the process (copyright
> etc).
> 
> Here is the ouput captured with DebugView for this crash:
> https://www.dropbox.com/s/m7wys0dewmc1wx4/gmic_crash.LOG?dl=0
Comment 17 Alvin Wong 2017-08-13 07:34:29 UTC
I think this is the problem:

#1  0x00000000004081b6 in gmic_qt_output_images (images=..., imageNames=..., mode=mode@entry=GmicQt::InPlace) at src\host_krita.cpp:266
266             memcpy(m->data(), gimg._data, m->size());


Looking at the code:

257             QSharedMemory *m = new QSharedMemory(QString("key_%1").arg(QUuid::createUuid().toString()));
258             sharedMemorySegments.append(m);
259
260             if (!m->create(gimg._width * gimg._height * gimg._spectrum * sizeof(float))) {
261                 qWarning() << "Could not create shared memory" << m->error() << m->errorString();
262                 return;
263             }
264
265             m->lock();
266             memcpy(m->data(), gimg._data, m->size());
267             m->unlock();


The size requested for `m` is:

(gdb) p gimg._width * gimg._height * gimg._spectrum * sizeof(float)
$12 = 52862080 (0x3269C80)


But the actual size for `m` is:

(gdb) p m->size()
$13 = 52862976 (0x326A000)


So it looks like at least on Windows, QSharedMemory can have a size larger than the requested size for alignment purpose.
It should use `gimg._width * gimg._height * gimg._spectrum * sizeof(float)` directly instead.
This might be a defect in Qt's documentation.
Why it didn't crash on other images is entirely due to sheer luck (it could've corrupted some other memory, who knows).

@Boud:
Please check all the usage of `QSharedMemory::size()` in both gmic-qt and Krita.
Comment 18 Alvin Wong 2017-08-13 07:49:09 UTC
(Reported upstream bug on the documentation: https://bugreports.qt.io/browse/QTBUG-62468)
Comment 19 Marcos Ebrahim 2017-08-13 08:03:55 UTC
Created attachment 107246 [details]
kritacrash.log

this time gmic take real time of processing and stop working .with sitting
fix file size 5gb undo 472 mg and changing memory limit and internal pool
couple of times lower and higher.

the report for this below

On Sun, Aug 13, 2017 at 9:49 AM, Alvin Wong <bugzilla_noreply@kde.org>
wrote:

> https://bugs.kde.org/show_bug.cgi?id=383339
>
> --- Comment #18 from Alvin Wong <alvinhochun@gmail.com> ---
> (Reported upstream bug on the documentation:
> https://bugreports.qt.io/browse/QTBUG-62468)
>
> --
> You are receiving this mail because:
> You reported the bug.
>
Comment 20 Marcos Ebrahim 2017-08-13 08:03:59 UTC
Created attachment 107247 [details]
gmic_Krita3.2.rc.3.1_crashNotclose_diff_mem_config_Error.LOG
Comment 21 Halla Rempt 2017-08-13 12:22:41 UTC
Okay, the memcpy error was only in gmic_qt. I'll make new test builds today for Windows x86 and x64.
Comment 22 Halla Rempt 2017-08-13 12:49:54 UTC
I've uploaded new builds to https://download.kde.org/unstable/krita/3.2.0-rc.3/ with, hopefully, working drmingw and the qsharedmemory size fix.
Comment 23 Silvio Grosso 2017-08-13 14:36:31 UTC
Hi Boud,

Just tested on Windows 7 (64 bit) today's new version (X64-setup.exe).
I can confirm it does not crash anymore :-)

At present, on my systems (Windows 7 - 8.1 - 10 all of them 64 bits; Intel I7; Nvidia GeForce ; 8 gb Ram) G'mic is too buggy though:
 - Most of the time filters are not applied to the images (even though their preview is always correct) when you click OK or apply ;
- When you click apply quite often the G'mic window gets closed automatically while it should remain open for further tweaking later on (until you click ok to confirm);
- Quite often the filter is applied only on some parte of the image (this is especially true for the filters in the Array & Tiles group)

Same filters work fine when applied with Gimp 2.8.20 and G'mic 2.0.2 (qt version).
For instance, I have tested Colorize filters with many images (jpeg) but it never worked on them (whereas with Gimp everything worked as expected)
But, sure, all these problems belong to another bug report since the crash is solved ! :-)
Comment 24 Marcos Ebrahim 2017-08-13 18:32:14 UTC
Created attachment 107262 [details]
kritacrash.log

Done :D

after crashing 3 times when I open the the picture on krita at start and
pen pressure not working . in the 4 th time I open krita every thing work
fine pressure sensitive , opening the picture and the gmic ok and apply
button. may be it could be as boud say previously antivirus issues because
I notice that avg after new update make hang on the new running program to
check it . I also attach the reports for those crashes if you will
recommend any settings with antivirus or any thing else.

Thanks for your super support in this problem specially and in krita
project at all.



On Sun, Aug 13, 2017 at 4:36 PM, Silvio Grosso <bugzilla_noreply@kde.org>
wrote:

> https://bugs.kde.org/show_bug.cgi?id=383339
>
> --- Comment #23 from Silvio Grosso <grossosilvio@yahoo.it> ---
> Hi Boud,
>
> Just tested on Windows 7 (64 bit) today's new version (X64-setup.exe).
> I can confirm it does not crash anymore :-)
>
> At present, on my systems (Windows 7 - 8.1 - 10 all of them 64 bits; Intel
> I7;
> Nvidia GeForce ; 8 gb Ram) G'mic is too buggy though:
>  - Most of the time filters are not applied to the images (even though
> their
> preview is always correct) when you click OK or apply ;
> - When you click apply quite often the G'mic window gets closed
> automatically
> while it should remain open for further tweaking later on (until you click
> ok
> to confirm);
> - Quite often the filter is applied only on some parte of the image (this
> is
> especially true for the filters in the Array & Tiles group)
>
> Same filters work fine when applied with Gimp 2.8.20 and G'mic 2.0.2 (qt
> version).
> For instance, I have tested Colorize filters with many images (jpeg) but it
> never worked on them (whereas with Gimp everything worked as expected)
> But, sure, all these problems belong to another bug report since the crash
> is
> solved ! :-)
>
> --
> You are receiving this mail because:
> You reported the bug.
>
Comment 25 Marcos Ebrahim 2017-08-13 18:32:17 UTC
Created attachment 107263 [details]
gmic_Krita3.2.rc.3.2.LOG