Bug 335121 - Kate has closed when trying to save a .gz file
Summary: Kate has closed when trying to save a .gz file
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: kwrite (other bugs)
Version First Reported In: 3.13.1
Platform: Ubuntu Linux
: NOR crash
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords: drkonqi
: 334717 336922 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-05-21 08:38 UTC by Guillaume Debray
Modified: 2015-10-04 11:47 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Guillaume Debray 2014-05-21 08:38:49 UTC
Application: kwrite (4.13.1)
KDE Platform Version: 4.13.1
Qt Version: 4.8.6
Operating System: Linux 3.13.0-24-generic x86_64
Distribution: Ubuntu 14.04 LTS

-- Information about the crash:
- What I was doing when the application crashed:
Trying to save a file changelog.gz, Kate as closed.
ame bug with Kwrite.

The crash can be reproduced every time.

-- Backtrace:
Application: KWrite (kwrite), signal: Segmentation fault
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Current thread is 1 (Thread 0x7f9512c397c0 (LWP 18200))]

Thread 3 (Thread 0x7f94fdd4b700 (LWP 18201)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00007f94ff905ffb in ?? () from /usr/lib/x86_64-linux-gnu/libQtScript.so.4
#2  0x00007f94ff906039 in ?? () from /usr/lib/x86_64-linux-gnu/libQtScript.so.4
#3  0x00007f950c8bf182 in start_thread (arg=0x7f94fdd4b700) at pthread_create.c:312
#4  0x00007f951257c30d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thread 2 (Thread 0x7f947a480700 (LWP 18203)):
#0  0x00007f951256efbd in poll () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007f950c3dffe4 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007f950c3e00ec in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f950fe327be in QEventDispatcherGlib::processEvents (this=0x7f94740008c0, flags=...) at kernel/qeventdispatcher_glib.cpp:436
#4  0x00007f950fe040af in QEventLoop::processEvents (this=this@entry=0x7f947a47fde0, flags=...) at kernel/qeventloop.cpp:149
#5  0x00007f950fe043a5 in QEventLoop::exec (this=this@entry=0x7f947a47fde0, flags=...) at kernel/qeventloop.cpp:204
#6  0x00007f950fd00c5f in QThread::exec (this=this@entry=0x2d059d0) at thread/qthread.cpp:537
#7  0x00007f950fde5823 in QInotifyFileSystemWatcherEngine::run (this=0x2d059d0) at io/qfilesystemwatcher_inotify.cpp:265
#8  0x00007f950fd0332f in QThreadPrivate::start (arg=0x2d059d0) at thread/qthread_unix.cpp:349
#9  0x00007f950c8bf182 in start_thread (arg=0x7f947a480700) at pthread_create.c:312
#10 0x00007f951257c30d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thread 1 (Thread 0x7f9512c397c0 (LWP 18200)):
[KCrash Handler]
#6  deflate (strm=0x2da1500, flush=0) at deflate.c:680
#7  0x00007f9510202f9c in KGzipFilter::compress (this=0x2d31ae0, finish=<optimized out>) at ../../kdecore/compression/kgzipfilter.cpp:363
#8  0x00007f951020513c in KFilterDev::writeData (this=0x22ff430, data=0x2c4a5d8 "dPluzz 2.1\n\n\t*am\303\251lioration du paquet deb\n\n\t-- cracolinux <cracolinux@mailoo.org>  Sun, 27 04 2014 16:27\n", len=105) at ../../kdecore/compression/kfilterdev.cpp:302
#9  0x00007f950fd93470 in QIODevice::write (this=0x22ff430, data=0x2c4a5d8 "dPluzz 2.1\n\n\t*am\303\251lioration du paquet deb\n\n\t-- cracolinux <cracolinux@mailoo.org>  Sun, 27 04 2014 16:27\n", maxSize=<optimized out>) at io/qiodevice.cpp:1371
#10 0x00007f950fda2b3d in write (data=..., this=<optimized out>) at ../../include/QtCore/../../src/corelib/io/qiodevice.h:127
#11 QTextStreamPrivate::flushWriteBuffer (this=0x2da17f0) at io/qtextstream.cpp:681
#12 0x00007f950fda3369 in QTextStream::flush (this=this@entry=0x7fff61482ec0) at io/qtextstream.cpp:1178
#13 0x00007f94fff01935 in Kate::TextBuffer::save (this=0x26cb100, filename=...) at ../../part/buffer/katetextbuffer.cpp:799
#14 0x00007f94fff71af0 in KateBuffer::saveFile (this=0x26cb100, m_file=...) at ../../part/document/katebuffer.cpp:273
#15 0x00007f94fff6baa7 in KateDocument::saveFile (this=0x26ca680) at ../../part/document/katedocument.cpp:2207
#16 0x00007f9511b6973a in KParts::ReadWritePart::save (this=0x26ca680) at ../../kparts/part.cpp:879
#17 0x00007f94fff50fe0 in KateDocument::documentSave (this=0x26ca680) at ../../part/document/katedocument.cpp:3905
#18 0x00007f94fff6dc51 in KateDocument::qt_static_metacall (_o=0x26ca680, _id=0, _a=0x7fff614832a0, _c=<optimized out>) at ./katedocument.moc:279
#19 0x00007f950fe1987a in QMetaObject::activate (sender=sender@entry=0x25a27b0, m=m@entry=0x7f95112a1de0 <QAction::staticMetaObject>, local_signal_index=local_signal_index@entry=1, argv=argv@entry=0x7fff614832a0) at kernel/qobject.cpp:3539
#20 0x00007f95107f1a62 in QAction::triggered (this=this@entry=0x25a27b0, _t1=false) at .moc/release-shared/moc_qaction.cpp:276
#21 0x00007f95107f3433 in QAction::activate (this=0x25a27b0, event=<optimized out>) at kernel/qaction.cpp:1257
#22 0x00007f9510baab02 in QAbstractButtonPrivate::click (this=this@entry=0x2b948d0) at widgets/qabstractbutton.cpp:530
#23 0x00007f9510baac2c in QAbstractButton::mouseReleaseEvent (this=0x2b14260, e=0x7fff614837a0) at widgets/qabstractbutton.cpp:1123
#24 0x00007f9510c61a4a in QToolButton::mouseReleaseEvent (this=<optimized out>, e=<optimized out>) at widgets/qtoolbutton.cpp:723
#25 0x00007f951084750a in QWidget::event (this=0x2b14260, event=0x7fff614837a0) at kernel/qwidget.cpp:8376
#26 0x00007f95107f7e2c in QApplicationPrivate::notify_helper (this=this@entry=0x2310900, receiver=receiver@entry=0x2b14260, e=e@entry=0x7fff614837a0) at kernel/qapplication.cpp:4567
#27 0x00007f95107fe5dd in QApplication::notify (this=this@entry=0x7fff61484020, receiver=receiver@entry=0x2b14260, e=e@entry=0x7fff614837a0) at kernel/qapplication.cpp:4110
#28 0x00007f9511502d1a in KApplication::notify (this=0x7fff61484020, receiver=0x2b14260, event=0x7fff614837a0) at ../../kdeui/kernel/kapplication.cpp:311
#29 0x00007f950fe054dd in QCoreApplication::notifyInternal (this=0x7fff61484020, receiver=receiver@entry=0x2b14260, event=event@entry=0x7fff614837a0) at kernel/qcoreapplication.cpp:953
#30 0x00007f95107fdd93 in sendEvent (event=<optimized out>, receiver=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:231
#31 QApplicationPrivate::sendMouseEvent (receiver=receiver@entry=0x2b14260, event=event@entry=0x7fff614837a0, alienWidget=alienWidget@entry=0x2b14260, nativeWidget=nativeWidget@entry=0x2b793d0, buttonDown=buttonDown@entry=0x7f95112dd318 <qt_button_down>, lastMouseReceiver=..., spontaneous=spontaneous@entry=true) at kernel/qapplication.cpp:3178
#32 0x00007f95108729cb in QETWidget::translateMouseEvent (this=this@entry=0x2b793d0, event=event@entry=0x7fff61483b20) at kernel/qapplication_x11.cpp:4634
#33 0x00007f9510872269 in QApplication::x11ProcessEvent (this=0x7fff61484020, event=event@entry=0x7fff61483b20) at kernel/qapplication_x11.cpp:3627
#34 0x00007f9510899b02 in x11EventSourceDispatch (s=0x2302400, callback=0x0, user_data=0x0) at kernel/qguieventdispatcher_glib.cpp:146
#35 0x00007f950c3dfe04 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#36 0x00007f950c3e0048 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#37 0x00007f950c3e00ec in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#38 0x00007f950fe327a1 in QEventDispatcherGlib::processEvents (this=0x22c2af0, flags=...) at kernel/qeventdispatcher_glib.cpp:434
#39 0x00007f9510899bb6 in QGuiEventDispatcherGlib::processEvents (this=<optimized out>, flags=...) at kernel/qguieventdispatcher_glib.cpp:204
#40 0x00007f950fe040af in QEventLoop::processEvents (this=this@entry=0x7fff61483ef0, flags=...) at kernel/qeventloop.cpp:149
#41 0x00007f950fe043a5 in QEventLoop::exec (this=this@entry=0x7fff61483ef0, flags=...) at kernel/qeventloop.cpp:204
#42 0x00007f950fe09b79 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1225
#43 0x00007f95107f637c in QApplication::exec () at kernel/qapplication.cpp:3828
#44 0x00007f9512856bc3 in kdemain (argc=2, argv=0x7fff61484178) at ../../kwrite/kwritemain.cpp:739
#45 0x00007f95124a2ec5 in __libc_start_main (main=0x4006d0 <main(int, char**)>, argc=2, argv=0x7fff61484178, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fff61484168) at libc-start.c:287
#46 0x00000000004006fe in _start ()

Reported using DrKonqi
Comment 1 Dominik Haumann 2014-06-07 12:15:20 UTC
Hm, we're just calling flush on the stream. David, could you have a look at the backtrace? This is KDE 4.13.1.
Comment 2 Dominik Haumann 2014-06-07 12:36:45 UTC
Can reproduce:

Application: KWrite (kwrite), signal: Segmentation fault
Using host libthread_db library "/lib64/libthread_db.so.1".
[KCrash Handler]
#5  0x00007f05e46ad922 in deflate () from /lib64/libz.so.1
#6  0x00007f05e74adfbc in KGzipFilter::compress (this=0x11942d0, finish=<optimized out>) at /usr/src/debug/kdelibs-4.13.1/kdecore/compression/kgzipfilter.cpp:363
#7  0x00007f05e74b015c in KFilterDev::writeData (this=0xe25640, data=0x11be0b8 "2000-08-12  Norman Walsh  <ndw@nwalsh.com>\n\n\t* 40chg.txt: Updated; changed version number\n\n\t* 41chg.txt, readme.txt: Updated; changed version number, release date\n\n\t* calstblx.dtd, dbcentx.mod, dbgene"..., len=3434) at /usr/src/debug/kdelibs-4.13.1/kdecore/compression/kfilterdev.cpp:302
#8  0x00007f05e7037830 in QIODevice::write(char const*, long long) () from /usr/lib64/libQtCore.so.4
#9  0x00007f05e7044c2d in ?? () from /usr/lib64/libQtCore.so.4
#10 0x00007f05d683eba0 in Kate::TextBuffer::save (this=0xccb700, filename=...) at /home/dh/kde/kate/part/buffer/katetextbuffer.cpp:799
#11 0x00007f05d68aa962 in KateBuffer::saveFile (this=0xccb700, m_file=...) at /home/dh/kde/kate/part/document/katebuffer.cpp:273
#12 0x00007f05d68a24c3 in KateDocument::saveFile (this=0xccac80) at /home/dh/kde/kate/part/document/katedocument.cpp:2207
#13 0x00007f05e9aceb7c in KParts::ReadWritePart::save() () from /usr/lib64/libkparts.so.4
#14 0x00007f05d688c813 in KateDocument::documentSave (this=0xccac80) at /home/dh/kde/kate/part/document/katedocument.cpp:3905
#15 0x00007f05d68a36c7 in KateDocument::qt_static_metacall (_o=0xccac80, _c=<optimized out>, _id=54, _a=0x7fff1df107c0) at /home/dh/kde/kate/build/part/katedocument.moc:279
Comment 3 Dominik Haumann 2014-06-07 12:41:52 UTC
Using valgrind, I get:

KGzipFilter: Unsupported mode  10 . Only QIODevice::ReadOnly and QIODevice::WriteOnly supported 
==15084== Conditional jump or move depends on uninitialised value(s)
==15084==    at 0xA6D78FB: deflate (in /lib64/libz.so.1.2.8)
==15084==    by 0x7759FBB: KGzipFilter::compress(bool) (kgzipfilter.cpp:363)
==15084==    by 0x775C15B: KFilterDev::writeData(char const*, long long) (kfilterdev.cpp:302)
==15084==    by 0x7C9582F: QIODevice::write(char const*, long long) (in /usr/lib64/libQtCore.so.4.8.5)
==15084==    by 0x7CA2C2C: ??? (in /usr/lib64/libQtCore.so.4.8.5)
==15084==    by 0x1A7A2B9F: Kate::TextBuffer::save(QString const&) (katetextbuffer.cpp:799)
==15084==    by 0x1A80E961: KateBuffer::saveFile(QString const&) (katebuffer.cpp:273)
==15084==    by 0x1A8064C2: KateDocument::saveFile() (katedocument.cpp:2207)
==15084==    by 0x52BFB7B: KParts::ReadWritePart::save() (in /usr/lib64/libkparts.so.4.13.1)
==15084==    by 0x1A7F0812: KateDocument::documentSave() (katedocument.cpp:3905)
==15084==    by 0x1A8076C6: KateDocument::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (katedocument.moc:279)
==15084==    by 0x7D18D67: QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (in /usr/lib64/libQtCore.so.4.8.5)
==15084== 
  deflate returned  -2
Comment 4 Dominik Haumann 2014-06-07 13:00:17 UTC
Again the trace with self-build libz version 1.2.8:

KGzipFilter: Unsupported mode  10 . Only QIODevice::ReadOnly and QIODevice::WriteOnly supported 
==16843== Conditional jump or move depends on uninitialised value(s)
==16843==    at 0xA6D7F36: deflate (deflate.c:672)
==16843==    by 0x7759FBB: KGzipFilter::compress(bool) (kgzipfilter.cpp:363)
==16843==    by 0x775C15B: KFilterDev::writeData(char const*, long long) (kfilterdev.cpp:302)
==16843==    by 0x7C9582F: QIODevice::write(char const*, long long) (in /usr/lib64/libQtCore.so.4.8.5)
==16843==    by 0x7CA2C2C: ??? (in /usr/lib64/libQtCore.so.4.8.5)
==16843==    by 0x1A7A9B9F: Kate::TextBuffer::save(QString const&) (katetextbuffer.cpp:799)
==16843==    by 0x1A815961: KateBuffer::saveFile(QString const&) (katebuffer.cpp:273)
==16843==    by 0x1A80D4C2: KateDocument::saveFile() (katedocument.cpp:2207)
==16843==    by 0x52BFB7B: KParts::ReadWritePart::save() (in /usr/lib64/libkparts.so.4.13.1)
==16843==    by 0x1A7F7812: KateDocument::documentSave() (katedocument.cpp:3905)
==16843==    by 0x1A80E6C6: KateDocument::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (katedocument.moc:279)
==16843==    by 0x7D18D67: QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (in /usr/lib64/libQtCore.so.4.8.5)
==16843== 
  deflate returned  -2 


defalte.c looks like this:
664 /* ========================================================================= */
665 int ZEXPORT deflate (strm, flush)
666     z_streamp strm;
667     int flush;
668 {
669     int old_flush; /* value of flush param for previous deflate call */
700     deflate_state *s;
701
702     if (strm == Z_NULL || strm->state == Z_NULL ||
703         flush > Z_BLOCK || flush < 0) {
704         return Z_STREAM_ERROR;
705     }
706     s = strm->state;

See: http://code.woboq.org/gcc/zlib/deflate.c.html#670
Comment 5 Dominik Haumann 2014-06-07 13:04:54 UTC
Not reproducible in KDE Frameworks 5.
Comment 6 Dominik Haumann 2014-06-07 13:21:23 UTC
*** Bug 334717 has been marked as a duplicate of this bug. ***
Comment 7 Dominik Haumann 2014-07-01 09:59:02 UTC
*** Bug 336922 has been marked as a duplicate of this bug. ***
Comment 8 Boris Egorov 2014-12-12 10:18:31 UTC
The key problem is this:
KGzipFilter: Unsupported mode 10 . Only QIODevice::ReadOnly and QIODevice::WriteOnly supported 

Kate pass QIODevice::WriteOnly | QIODevice::Truncate flags to KGzipFilter, which can accept only QIODevice::WriteOnly. KGzipFilter don't run deflateInit2() and following call to deflate() fails.

Problem is solved about a year ago with this commit:

commit 84ed5e973ad22936c2b5813b9421f859002d33e3
Author: Christoph Cullmann <cullmann@kde.org>
Date:   Tue Dec 31 14:53:05 2013 +0100

    filter device doesn't like truncate

diff --git a/part/buffer/katetextbuffer.cpp b/part/buffer/katetextbuffer.cpp
index c63c1cb..05acfeb 100644
--- a/part/buffer/katetextbuffer.cpp
+++ b/part/buffer/katetextbuffer.cpp
@@ -735,7 +735,7 @@ bool TextBuffer::save (const QString &filename)
   /**
    * try to open, if new file
    */
-  if (!file.open (QIODevice::WriteOnly | QIODevice::Truncate))
+  if (!file.open (QIODevice::WriteOnly))
     return false;
 
   /**
Comment 9 Christoph Cullmann 2015-10-04 11:47:44 UTC
Then all is fine, if the above patch is in KF5.