Bug 289145

Summary: Krita crash while using sketch brush
Product: [Applications] krita Reporter: Philippe Nicloux <phil.nicloux>
Component: GeneralAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: crash CC: dimula73, lukast.dev, phil.nicloux
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: New crash information added by DrKonqi

Description Philippe Nicloux 2011-12-16 21:29:58 UTC
Application: krita (2.4 Beta 5)
KDE Platform Version: 4.6.5 (4.6.5)
Qt Version: 4.7.2
Operating System: Linux 2.6.38-13-generic x86_64
Distribution: Linux Mint 11 Katya

-- Information about the crash:
- What I was doing when the application crashed: i was changing parameters in sketch brush settings, and trying them in the test window. I use a wacom tablet

-- Backtrace:
Application: Krita (krita), signal: Segmentation fault
[Current thread is 1 (Thread 0x7ff5a73337a0 (LWP 9127))]

Thread 7 (Thread 0x7ff59734f700 (LWP 9128)):
#0  0x00007ff59efb93ce in pthread_mutex_lock () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00007ff59e4d9669 in g_main_context_acquire () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007ff59e4daf21 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007ff59e4db9f2 in g_main_loop_run () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#4  0x00007ff597caec44 in ?? () from /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
#5  0x00007ff59e5023e4 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#6  0x00007ff59efb6d8c in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#7  0x00007ff59f2b404d in clone () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x0000000000000000 in ?? ()

Thread 6 (Thread 0x7ff57a26b700 (LWP 9134)):
#0  0x00007ff59efbbbac in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00007ff5a6afc82b in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib/libQtCore.so.4
#2  0x00007ff5a6af9235 in QSemaphore::acquire(int) () from /usr/lib/libQtCore.so.4
#3  0x00007ff5a61532fe in KisTileDataPooler::waitForWork (this=0x1b3c130) at /home/filou/source-to-compile/calligra/calligra-src/krita/image/tiles3/kis_tile_data_pooler.cc:162
#4  0x00007ff5a61539e4 in KisTileDataPooler::run (this=0x1b3c130) at /home/filou/source-to-compile/calligra/calligra-src/krita/image/tiles3/kis_tile_data_pooler.cc:184
#5  0x00007ff5a6afc175 in ?? () from /usr/lib/libQtCore.so.4
#6  0x00007ff59efb6d8c in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#7  0x00007ff59f2b404d in clone () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x0000000000000000 in ?? ()

Thread 5 (Thread 0x7ff579a6a700 (LWP 9135)):
#0  0x00007ff59efbbbac in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00007ff5a6afc82b in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib/libQtCore.so.4
#2  0x00007ff5a6af9469 in QSemaphore::tryAcquire(int, int) () from /usr/lib/libQtCore.so.4
#3  0x00007ff5a6173dea in KisTileDataSwapper::run (this=0x1b3c168) at /home/filou/source-to-compile/calligra/calligra-src/krita/image/tiles3/swap/kis_tile_data_swapper.cpp:92
#4  0x00007ff5a6afc175 in ?? () from /usr/lib/libQtCore.so.4
#5  0x00007ff59efb6d8c in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#6  0x00007ff59f2b404d in clone () from /lib/x86_64-linux-gnu/libc.so.6
#7  0x0000000000000000 in ?? ()

Thread 4 (Thread 0x7ff578a68700 (LWP 9143)):
#0  0x00007ff59efbbbac in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00007ff5a6afc82b in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib/libQtCore.so.4
#2  0x00007ff5a0d567d4 in ?? () from /usr/lib/libQtGui.so.4
#3  0x00007ff5a6afc175 in ?? () from /usr/lib/libQtCore.so.4
#4  0x00007ff59efb6d8c in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#5  0x00007ff59f2b404d in clone () from /lib/x86_64-linux-gnu/libc.so.6
#6  0x0000000000000000 in ?? ()

Thread 3 (Thread 0x7ff579269700 (LWP 9144)):
#0  0xffffffffff60017b in ?? ()
#1  0x00007ff579268bd0 in ?? ()
#2  0x00007ffff37117b2 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 2 (Thread 0x7ff571632700 (LWP 9166)):
[KCrash Handler]
#6  0x00007ff5a61d96a9 in calcAngle (y=-nan(0x8000000000000), x=nan(0x8000000000000)) at /home/filou/source-to-compile/calligra/calligra-src/krita/image/kis_fast_math.cpp:77
#7  KisFastMath::atan2 (y=-nan(0x8000000000000), x=nan(0x8000000000000)) at /home/filou/source-to-compile/calligra/calligra-src/krita/image/kis_fast_math.cpp:131
#8  0x00007ff5a621e48e in KisCircleMaskGenerator::valueAt (this=0x7ff56d3381e0, x=<value optimized out>, y=<value optimized out>) at /home/filou/source-to-compile/calligra/calligra-src/krita/image/kis_circle_mask_generator.cpp:59
#9  0x00007ff5813b0f45 in process (this=0xfff8000000000000, dst=) at /home/filou/source-to-compile/calligra/calligra-src/krita/plugins/paintops/libbrush/kis_auto_brush.cpp:95
#10 KisAutoBrush::generateMaskAndApplyMaskOrCreateDab (this=0xfff8000000000000, dst=) at /home/filou/source-to-compile/calligra/calligra-src/krita/plugins/paintops/libbrush/kis_auto_brush.cpp:351
#11 0x00007ff5813b5a7a in KisBrush::mask (this=0x7ff53af17e30, dst=..., color=<value optimized out>, scaleX=<value optimized out>, scaleY=<value optimized out>, angle=<value optimized out>, info=..., subPixelX=<value optimized out>, subPixelY=<value optimized out>, softnessFactor=<value optimized out>) at /home/filou/source-to-compile/calligra/calligra-src/krita/plugins/paintops/libbrush/kis_brush.cpp:367
#12 0x00007ff57e79acfb in KisSketchPaintOp::updateBrushMask (this=0x7ff56ed53770, info=..., scale=0, rotation=0) at /home/filou/source-to-compile/calligra/calligra-src/krita/plugins/paintops/sketch/kis_sketch_paintop.cpp:104
#13 0x00007ff57e79b01a in KisSketchPaintOp::paintLine (this=0x7ff56ed53770, pi1=..., pi2=..., savedDist=<value optimized out>) at /home/filou/source-to-compile/calligra/calligra-src/krita/plugins/paintops/sketch/kis_sketch_paintop.cpp:156
#14 0x00007ff5a6186523 in paintBezierCurve (paintOp=0x7ff56ed53770, pi1=..., control1=..., control2=..., pi2=..., savedDist=...) at /home/filou/source-to-compile/calligra/calligra-src/krita/image/brushengine/kis_paintop.cc:122
#15 0x00007ff5a61865a5 in KisPaintOp::paintBezierCurve (this=<value optimized out>, pi1=<value optimized out>, control1=<value optimized out>, control2=<value optimized out>, pi2=<value optimized out>, savedDist=<value optimized out>) at /home/filou/source-to-compile/calligra/calligra-src/krita/image/brushengine/kis_paintop.cc:149
#16 0x00007ff5a617490d in KisPainter::paintBezierCurve (this=0xf701680, pi1=..., control1=..., control2=..., pi2=..., savedDist=...) at /home/filou/source-to-compile/calligra/calligra-src/krita/image/kis_painter.cc:1077
#17 0x00007ff5a67903f8 in FreehandStrokeStrategy::doStrokeCallback (this=<value optimized out>, data=<value optimized out>) at /home/filou/source-to-compile/calligra/calligra-src/krita/ui/tool/strokes/freehand_stroke.cpp:73
#18 0x00007ff5a614f129 in run (this=0x70c8d70) at /home/filou/source-to-compile/calligra/calligra-build/krita/image/../../../calligra-src/krita/image/kis_stroke_job.h:39
#19 KisUpdateJobItem::run (this=0x70c8d70) at /home/filou/source-to-compile/calligra/calligra-build/krita/image/../../../calligra-src/krita/image/kis_update_job_item.h:59
#20 0x00007ff5a6af1188 in ?? () from /usr/lib/libQtCore.so.4
#21 0x00007ff5a6afc175 in ?? () from /usr/lib/libQtCore.so.4
#22 0x00007ff59efb6d8c in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#23 0x00007ff59f2b404d in clone () from /lib/x86_64-linux-gnu/libc.so.6
#24 0x0000000000000000 in ?? ()

Thread 1 (Thread 0x7ff5a73337a0 (LWP 9127)):
#0  0x00007ff59f2a6f03 in poll () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007ff59cd5a512 in ?? () from /usr/lib/x86_64-linux-gnu/libxcb.so.1
#2  0x00007ff59cd5aa5f in ?? () from /usr/lib/x86_64-linux-gnu/libxcb.so.1
#3  0x00007ff59cd5aae4 in xcb_writev () from /usr/lib/x86_64-linux-gnu/libxcb.so.1
#4  0x00007ff5a53a72a7 in _XSend () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#5  0x00007ff5a53a77fb in _XReply () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#6  0x00007ff5a538b365 in XGetImage () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#7  0x00007ff5a094bcdb in QX11PixmapData::toImage(QRect const&) const () from /usr/lib/libQtGui.so.4
#8  0x00007ff5a094805a in QX11PixmapData::toImage() const () from /usr/lib/libQtGui.so.4
#9  0x00007ff5a0936a70 in QPixmap::toImage() const () from /usr/lib/libQtGui.so.4
#10 0x00007ff5a0975be3 in QBrush::textureImage() const () from /usr/lib/libQtGui.so.4
#11 0x00007ff5a0a2535a in ?? () from /usr/lib/libQtGui.so.4
#12 0x00007ff5a0a260aa in ?? () from /usr/lib/libQtGui.so.4
#13 0x00007ff5a0a2639a in ?? () from /usr/lib/libQtGui.so.4
#14 0x00007ff5a099892d in QPaintEngineEx::draw(QVectorPath const&) () from /usr/lib/libQtGui.so.4
#15 0x00007ff5a09a8570 in ?? () from /usr/lib/libQtGui.so.4
#16 0x00007ff5a09aa1d8 in QPainter::drawRects(QRectF const*, int) () from /usr/lib/libQtGui.so.4
#17 0x00007ff5a09ae166 in QPainter::drawPixmap(QRectF const&, QPixmap const&, QRectF const&) () from /usr/lib/libQtGui.so.4
#18 0x00007ff5a0bd1e92 in QGtkStyle::drawPrimitive(QStyle::PrimitiveElement, QStyleOption const*, QPainter*, QWidget const*) const () from /usr/lib/libQtGui.so.4
#19 0x00007ff5a0b6d660 in QCommonStyle::drawControl(QStyle::ControlElement, QStyleOption const*, QPainter*, QWidget const*) const () from /usr/lib/libQtGui.so.4
#20 0x00007ff5a0c05a2d in QWindowsStyle::drawControl(QStyle::ControlElement, QStyleOption const*, QPainter*, QWidget const*) const () from /usr/lib/libQtGui.so.4
#21 0x00007ff5a0bf04c4 in QCleanlooksStyle::drawControl(QStyle::ControlElement, QStyleOption const*, QPainter*, QWidget const*) const () from /usr/lib/libQtGui.so.4
#22 0x00007ff5a0bd80a4 in QGtkStyle::drawControl(QStyle::ControlElement, QStyleOption const*, QPainter*, QWidget const*) const () from /usr/lib/libQtGui.so.4
#23 0x00007ff5a0c6003b in QFrame::drawFrame(QPainter*) () from /usr/lib/libQtGui.so.4
#24 0x00007ff5a0c600cf in QFrame::paintEvent(QPaintEvent*) () from /usr/lib/libQtGui.so.4
#25 0x00007ff5a08adc7a in QWidget::event(QEvent*) () from /usr/lib/libQtGui.so.4
#26 0x00007ff5a0c60156 in QFrame::event(QEvent*) () from /usr/lib/libQtGui.so.4
#27 0x00007ff5a085c9f4 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQtGui.so.4
#28 0x00007ff5a08613ba in QApplication::notify(QObject*, QEvent*) () from /usr/lib/libQtGui.so.4
#29 0x00007ff5a15806c6 in KApplication::notify(QObject*, QEvent*) () from /usr/lib/libkdeui.so.5
#30 0x00007ff5a6be349c in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/libQtCore.so.4
#31 0x00007ff5a08aaacd in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) () from /usr/lib/libQtGui.so.4
#32 0x00007ff5a08ab6e2 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) () from /usr/lib/libQtGui.so.4
#33 0x00007ff5a08aa80c in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) () from /usr/lib/libQtGui.so.4
#34 0x00007ff5a08ab6e2 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) () from /usr/lib/libQtGui.so.4
#35 0x00007ff5a08aa80c in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) () from /usr/lib/libQtGui.so.4
#36 0x00007ff5a0a719eb in ?? () from /usr/lib/libQtGui.so.4
#37 0x00007ff5a08a0f60 in QWidgetPrivate::syncBackingStore() () from /usr/lib/libQtGui.so.4
#38 0x00007ff5a08ae194 in QWidget::event(QEvent*) () from /usr/lib/libQtGui.so.4
#39 0x00007ff5a0c60156 in QFrame::event(QEvent*) () from /usr/lib/libQtGui.so.4
#40 0x00007ff5a085c9f4 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQtGui.so.4
#41 0x00007ff5a08613ba in QApplication::notify(QObject*, QEvent*) () from /usr/lib/libQtGui.so.4
#42 0x00007ff5a15806c6 in KApplication::notify(QObject*, QEvent*) () from /usr/lib/libkdeui.so.5
#43 0x00007ff5a6be349c in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/libQtCore.so.4
#44 0x00007ff5a6be6c25 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /usr/lib/libQtCore.so.4
#45 0x00007ff5a6c10fdb in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#46 0x00007ff5a09072ec in ?? () from /usr/lib/libQtGui.so.4
#47 0x00007ff5a6be2882 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#48 0x00007ff5a6be2abc in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#49 0x00007ff5a6be6ecb in QCoreApplication::exec() () from /usr/lib/libQtCore.so.4
#50 0x00007ff5a6f1ec2d in kdemain (argc=<value optimized out>, argv=<value optimized out>) at /home/filou/source-to-compile/calligra/calligra-src/krita/main.cc:71
#51 0x00007ff59f1eceff in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6
#52 0x0000000000400899 in _start ()

Reported using DrKonqi
Comment 1 Sven Langkamp 2011-12-16 21:34:03 UTC
Which values did you change and to what did you change them?
Comment 2 Philippe Nicloux 2011-12-16 22:01:55 UTC
Le 16/12/2011 22:34, Sven Langkamp a écrit :
> https://bugs.kde.org/show_bug.cgi?id=289145
>
>
>
>
>
> --- Comment #1 from Sven Langkamp<sven langkamp gmail com>   2011-12-16 21:34:03 ---
> Which values did you change and to what did you change them?
>
Hmm... I think it was randomness and spacing, and I trying randomly, 
just to play... the crash happened very fast.
Comment 3 Sven Langkamp 2011-12-16 22:12:04 UTC
Could you try if you get the crash again and check what you changed?
Comment 4 Philippe Nicloux 2011-12-16 22:24:16 UTC
Le 16/12/2011 23:12, Sven Langkamp a écrit :
> https://bugs.kde.org/show_bug.cgi?id=289145
>
>
>
>
>
> --- Comment #3 from Sven Langkamp<sven langkamp gmail com>   2011-12-16 22:12:04 ---
> Could you try if you get the crash again and check what you changed?
>
ok, i tried again, I changed "spikes", and as soon as I begin to draw in 
the test window, crash !
Comment 5 LukasT 2011-12-17 15:04:18 UTC
I tried to reproduce, but I was not able.

I tested with wacom tablet and I changed the spikes, no problem, no crash
Here is the proof http://wstaw.org/m/2011/12/17/plasma-desktopeB1699.jpg

Can you try to reproduce and paste the backtrace again please?
Comment 6 Sven Langkamp 2011-12-17 16:54:27 UTC
I found out how to reproduce it:
-set spikes to some values
-go to the size option and set the slider to 0
-paint in the scratchpad
->crash
Comment 7 Dmitry Kazakov 2011-12-18 09:25:19 UTC
Changing spikes number from 2 to 3 crashes Krita on mouseRealeaseEvent.

*But*, it doesn't crash under gdb.
Comment 8 Dmitry Kazakov 2011-12-18 09:37:55 UTC
Update:
I get a full X11 hang when doing the following:

1) Run Krita in gdb
2) Choose Sketch Brush
3) Choose Line Width to 4px (important)
4) Choose number of spikes > 2
5) Paint with Tablet (important) on a scratch box

After mouseReleaseEvent, the entire X11 hangs up until I kill Krita with SIGKILL.
Comment 9 Dmitry Kazakov 2011-12-18 09:42:04 UTC
If at the step 5 I will paint on real canvas instead of scratchbox, then I get a crash with the same backtrace as Philippe Nicloux got. No hangups happen. But I still have to use Tablet.
Comment 10 Dmitry Kazakov 2011-12-18 10:12:02 UTC
I got the problem. The reason of this bug is that most of the tools call to 

const double scale = m_sizeOption.apply(pi);

But not all of them check the value for being zero. So in some cases they get division by zero.

Affected brushes:
KisSketchPaintOp
KisComplexOp
KisDuplicateOp
KisDeformBrush
KisHairyPaintOp
KisSprayPaintOp
Comment 11 Dmitry Kazakov 2011-12-18 11:20:51 UTC
Waiting for a review:
https://git.reviewboard.kde.org/r/103445/
Comment 12 Philippe Nicloux 2011-12-18 13:10:11 UTC
Le 18/12/2011 12:20, Dmitry Kazakov a écrit :
> https://bugs.kde.org/show_bug.cgi?id=289145
>
>
> Dmitry Kazakov<dimula73@gmail.com>  changed:
>
>             What    |Removed                     |Added
> ----------------------------------------------------------------------------
>               Status|ASSIGNED                    |RESOLVED
>           Resolution|                            |WAITINGFORINFO
>
>
>
>
> --- Comment #11 from Dmitry Kazakov<dimula73 gmail com>   2011-12-18 11:20:51 ---
> Waiting for a review:
> https://git.reviewboard.kde.org/r/103445/
>
Hello,
for me, it's always the same, I just have to change spikes parameters, 
the then, crash, on the scratchpad or on the page.
Comment 13 Philippe Nicloux 2011-12-18 13:15:24 UTC
Created attachment 66859 [details]
New crash information added by DrKonqi

krita (2.4 Beta 5) on KDE Platform 4.6.5 (4.6.5) using Qt 4.7.2

- What I was doing when the application crashed:I was changing "spikes"parameters in sketch tool

-- Backtrace (Reduced):
#6  0x00007f9f49de9ff9 in calcAngle (y=-nan(0x8000000000000), x=nan(0x8000000000000)) at /home/filou/source-to-compile/calligra/calligra-src/krita/image/kis_fast_math.cpp:77
#7  KisFastMath::atan2 (y=-nan(0x8000000000000), x=nan(0x8000000000000)) at /home/filou/source-to-compile/calligra/calligra-src/krita/image/kis_fast_math.cpp:131
#8  0x00007f9f49e2edde in KisCircleMaskGenerator::valueAt (this=0xeeeda90, x=<value optimized out>, y=<value optimized out>) at /home/filou/source-to-compile/calligra/calligra-src/krita/image/kis_circle_mask_generator.cpp:59
#9  0x00007f9f28fc7135 in process (this=0xfff8000000000000, dst=) at /home/filou/source-to-compile/calligra/calligra-src/krita/plugins/paintops/libbrush/kis_auto_brush.cpp:95
#10 KisAutoBrush::generateMaskAndApplyMaskOrCreateDab (this=0xfff8000000000000, dst=) at /home/filou/source-to-compile/calligra/calligra-src/krita/plugins/paintops/libbrush/kis_auto_brush.cpp:351
Comment 14 Dmitry Kazakov 2011-12-18 16:04:12 UTC
Git commit 92de02b1c01364e12dc157bee906eb6b3c85900f by Dmitry Kazakov.
Committed on 18/12/2011 at 13:17.
Pushed by dkazakov into branch 'master'.

Added checks for 'zero'ness of the scale of the brush

When using tablet, the last events coming from it are almost zero,
so the resulting scale is zero as well. Default mask generator will get
crazy if it gets zero scale due to division by zero. So we need to check
in most of the tools whether the scale is not zero.

BUG:289145

M  +2    -0    krita/plugins/paintops/complexop/kis_complexop.cpp
M  +2    -0    krita/plugins/paintops/defaultpaintops/duplicate/kis_duplicateop.cpp
M  +3    -0    krita/plugins/paintops/deform/kis_deform_paintop.cpp
M  +2    -0    krita/plugins/paintops/hairy/kis_hairy_paintop.cpp
M  +5    -4    krita/plugins/paintops/sketch/kis_sketch_paintop.cpp
M  +2    -0    krita/plugins/paintops/spray/kis_spray_paintop.cpp

http://commits.kde.org/calligra/92de02b1c01364e12dc157bee906eb6b3c85900f