Bug 176613

Summary: selecting File --> Print --> causes crash in konqueror with ASSERT in qprintdialog_unix.cpp \"index >= 0\"
Product: [Unmaintained] kdelibs Reporter: A. Spehr <zahl>
Component: qtAssignee: kdelibs bugs <kdelibs-bugs>
Status: RESOLVED UPSTREAM    
Severity: crash CC: faure, jlayt, zahl, zander
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description A. Spehr 2008-12-01 10:51:24 UTC
Version:           Version 4.1.81 (KDE 4.1.81 (KDE 4.2 >= 20081128)) (using Devel)
OS:                Linux
Installed from:    Compiled sources

Non-reproducible :(

I tried twice to repeat this and couldn't.

I was on bugs.kde.org, picked "file" then "print", and konq crashed with this backtrace (note the ASSERT in thread #1):

Application: Konqueror (konqueror), signal SIGABRT
[Current thread is 0 (LWP 326)]

Thread 4 (Thread 0xafff5b90 (LWP 463)):
#0  0xb7f9e430 in __kernel_vsyscall ()
#1  0xb66e3931 in select () from /lib/i686/cmov/libc.so.6
#2  0xb738b24b in QProcessManager::run (this=0x8bf7eb8) at io/qprocess_unix.cpp:301
#3  0xb72b8635 in QThreadPrivate::start (arg=0x8bf7eb8) at thread/qthread_unix.cpp:185
#4  0xb722d4c0 in start_thread () from /lib/i686/cmov/libpthread.so.0
#5  0xb66eb55e in clone () from /lib/i686/cmov/libc.so.6

Thread 3 (Thread 0xac6ceb90 (LWP 20824)):
#0  0xb7f9e430 in __kernel_vsyscall ()
#1  0xb7231025 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/i686/cmov/libpthread.so.0
#2  0xb72b8f58 in QWaitConditionPrivate::wait (this=0xc4d1b50, time=4294967295) at thread/qwaitcondition_unix.cpp:82
#3  0xb72b8a57 in QWaitCondition::wait (this=0xb73457c, mutex=0xb734578, time=4294967295) at thread/qwaitcondition_unix.cpp:154
#4  0xb6ffc651 in QFileInfoGatherer::run (this=0xb734570) at dialogs/qfileinfogatherer.cpp:191
#5  0xb72b8635 in QThreadPrivate::start (arg=0xb734570) at thread/qthread_unix.cpp:185
#6  0xb722d4c0 in start_thread () from /lib/i686/cmov/libpthread.so.0
#7  0xb66eb55e in clone () from /lib/i686/cmov/libc.so.6

Thread 2 (Thread 0xacecfb90 (LWP 20825)):
#0  0xb642b54a in clock_gettime () from /lib/i686/cmov/librt.so.1
#1  0xb73d8318 in QTimerInfoList::getTime (this=0xdc51334, t=@0xdc51358) at kernel/qeventdispatcher_unix.cpp:335
#2  0xb73d854b in QTimerInfoList::updateCurrentTime (this=0xdc51334) at kernel/qeventdispatcher_unix.cpp:293
#3  0xb73d8c13 in QTimerInfoList::timerWait (this=0xdc51334, tm=@0xacecf0fc) at kernel/qeventdispatcher_unix.cpp:416
#4  0xb73d6592 in timerSourcePrepare (source=0xdc51300, timeout=0xacecf158) at kernel/qeventdispatcher_glib.cpp:136
#5  0xb63ae1d4 in g_main_context_prepare () from /usr/lib/libglib-2.0.so.0
#6  0xb63ae65a in ?? () from /usr/lib/libglib-2.0.so.0
#7  0x105f3928 in ?? ()
#8  0xacecf1c8 in ?? ()
#9  0x10ce7780 in ?? ()
#10 0x00000001 in ?? ()
#11 0x00000002 in ?? ()
#12 0xb6426c08 in ?? () from /usr/lib/libglib-2.0.so.0
#13 0xb6426858 in ?? () from /usr/lib/libglib-2.0.so.0
#14 0xb7231ed5 in pthread_getspecific () from /lib/i686/cmov/libpthread.so.0
#15 0xb63aeb31 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#16 0xb73d5792 in QEventDispatcherGlib::processEvents (this=0xea4a378, flags={i = -1393757624}) at kernel/qeventdispatcher_glib.cpp:321
#17 0xb73a4ac8 in QEventLoop::processEvents (this=0xacecf2bc, flags={i = -1393757564}) at kernel/qeventloop.cpp:143
#18 0xb73a4d05 in QEventLoop::exec (this=0xacecf2bc, flags={i = -1393757500}) at kernel/qeventloop.cpp:190
#19 0xb72b4a65 in QThread::exec (this=0x10e67448) at thread/qthread.cpp:458
#20 0xb738ca05 in QInotifyFileSystemWatcherEngine::run (this=0x10e67448) at io/qfilesystemwatcher_inotify.cpp:205
#21 0xb72b8635 in QThreadPrivate::start (arg=0x10e67448) at thread/qthread_unix.cpp:185
#22 0xb722d4c0 in start_thread () from /lib/i686/cmov/libpthread.so.0
#23 0xb66eb55e in clone () from /lib/i686/cmov/libc.so.6

Thread 1 (Thread 0xb60bf700 (LWP 326)):
[KCrash Handler]
#6  0xb7f9e430 in __kernel_vsyscall ()
#7  0xb6636640 in raise () from /lib/i686/cmov/libc.so.6
#8  0xb6638018 in abort () from /lib/i686/cmov/libc.so.6
#9  0xb72ae9fb in qt_message_output (msgType=QtFatalMsg, buf=0xbffb45f0 "ASSERT: \"index >= 0\" in file dialogs/qprintdialog_unix.cpp, line 731") at global/qglobal.cpp:2102
#10 0xb72aea5f in qFatal (msg=0xb73fadb8 "ASSERT: \"%s\" in file %s, line %d") at global/qglobal.cpp:2303
#11 0xb72aee81 in qt_assert (assertion=0xb7184f2f "index >= 0", file=0xb7184f11 "dialogs/qprintdialog_unix.cpp", line=731) at global/qglobal.cpp:1872
#12 0xb6fb16dc in QUnixPrintWidgetPrivate::_q_printerChanged (this=0xb6e9fd0, index=-1) at dialogs/qprintdialog_unix.cpp:731
#13 0xb6fb1db0 in QUnixPrintWidgetPrivate::setOptionsPane (this=0xb6e9fd0, pane=0x106ea1b8) at dialogs/qprintdialog_unix.cpp:797
#14 0xb6fb368a in QPrintDialogPrivate::init (this=0x106ea1b8) at dialogs/qprintdialog_unix.cpp:389
#15 0xb6fb3a5b in QPrintDialog (this=0xde1e840, printer=0xbffb68d8, parent=0x9051fc8) at dialogs/qprintdialog_unix.cpp:577
#16 0xb7837b87 in KdePrint::createPrintDialog (printer=0xbffb68d8, customTabs=@0xbffb68f0, parent=0x9051fc8) at /home/ax4/kde/src/KDE/kdelibs/kdeui/dialogs/kdeprintdialog.cpp:40
#17 0xb3ebdaa3 in KHTMLView::print (this=0x9051fc8, quick=false) at /home/ax4/kde/src/KDE/kdelibs/khtml/khtmlview.cpp:3186
#18 0xb3f46e8a in KHTMLPartBrowserExtension::print (this=0x905efc0) at /home/ax4/kde/src/KDE/kdelibs/khtml/khtml_ext.cpp:369
#19 0xb3f482ec in KHTMLPartBrowserExtension::qt_metacall (this=0x905efc0, _c=QMetaObject::InvokeMetaMethod, _id=7, _a=0xbffb6bec) at /home/ax4/kde/build/KDE/kdelibs/khtml/khtml_ext.moc:96
#20 0xb73bc175 in QMetaObject::activate (sender=0x8de2408, from_signal_index=5, to_signal_index=6, argv=0xbffb6bec) at kernel/qobject.cpp:3028
#21 0xb73bc38e in QMetaObject::activate (sender=0x8de2408, m=0xb7207eb8, from_local_signal_index=1, to_local_signal_index=2, argv=0xbffb6bec) at kernel/qobject.cpp:3121
#22 0xb6b1b95a in QAction::triggered (this=0x8de2408, _t1=false) at .moc/debug-shared/moc_qaction.cpp:216
#23 0xb6b1d528 in QAction::activate (this=0x8de2408, event=QAction::Trigger) at kernel/qaction.cpp:1125
#24 0xb6f351c9 in QMenuPrivate::activateAction (this=0x8f90908, action=0x8de2408, action_e=QAction::Trigger, self=true) at widgets/qmenu.cpp:1002
#25 0xb6f36cbd in QMenu::mouseReleaseEvent (this=0x8f90458, e=0xbffb7424) at widgets/qmenu.cpp:2169
#26 0xb79acd0a in KMenu::mouseReleaseEvent (this=0x8f90458, e=0xbffb7424) at /home/ax4/kde/src/KDE/kdelibs/kdeui/widgets/kmenu.cpp:454
#27 0xb6b7f284 in QWidget::event (this=0x8f90458, event=0xbffb7424) at kernel/qwidget.cpp:7163
#28 0xb6f34db0 in QMenu::event (this=0x8f90458, e=0xbffb7424) at widgets/qmenu.cpp:2265
#29 0xb6b234c1 in QApplicationPrivate::notify_helper (this=0x8bf4a18, receiver=0x8f90458, e=0xbffb7424) at kernel/qapplication.cpp:3803
#30 0xb6b2403f in QApplication::notify (this=0xbffb7d60, receiver=0x8f90458, e=0xbffb7424) at kernel/qapplication.cpp:3528
#31 0xb78cbc13 in KApplication::notify (this=0xbffb7d60, receiver=0x8f90458, event=0xbffb7424) at /home/ax4/kde/src/KDE/kdelibs/kdeui/kernel/kapplication.cpp:307
#32 0xb73a7aa7 in QCoreApplication::notifyInternal (this=0xbffb7d60, receiver=0x8f90458, event=0xbffb7424) at kernel/qcoreapplication.cpp:583
#33 0xb6b2f38f in QCoreApplication::sendSpontaneousEvent (receiver=0x8f90458, event=0xbffb7424) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:212
#34 0xb6b27e96 in QApplicationPrivate::sendMouseEvent (receiver=0x8f90458, event=0xbffb7424, alienWidget=0x0, nativeWidget=0x8f90458, buttonDown=0xb7225b80, lastMouseReceiver=@0xb7225b84)
    at kernel/qapplication.cpp:2793
#35 0xb6b9e464 in QETWidget::translateMouseEvent (this=0x8f90458, event=0xbffb79c0) at kernel/qapplication_x11.cpp:3978
#36 0xb6b9f3f9 in QApplication::x11ProcessEvent (this=0xbffb7d60, event=0xbffb79c0) at kernel/qapplication_x11.cpp:3040
#37 0xb6bc8b62 in x11EventSourceDispatch (s=0x8bf7b28, callback=0, user_data=0x0) at kernel/qguieventdispatcher_glib.cpp:142
#38 0xb63ab2e1 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#39 0xb63ae973 in ?? () from /usr/lib/libglib-2.0.so.0
#40 0x08bf6e40 in ?? ()
#41 0x00000000 in ?? ()

I can't tell if this is a Qt bug or a KDE bug.
Comment 1 John Layt 2008-12-01 16:04:56 UTC
I've also seen this, but I had initially attributed it to either my hacking around with qt-copy, or not actually having any printers installed.

Using a clean qt-copy I get it consistently when trying to print from kwrite (I haven't tried other apps yet).  Using a freshly compiled download of Qt 4.4.3 I initially didn't get it but later did.  Using openSuse 11.1 Qt 4.4.3 packages I haven't seen it at all (yet).

I have a vague recollection tzander mentioned somewhere about problems with asserts being the root of the print problem in Qt 4.4.0?

Can you  confirm what qt you are using, and that you have real printers configured?

I'll try a few variations on this tonight.
Comment 2 A. Spehr 2008-12-02 00:04:21 UTC
No printers installed, and a recent compile of qt-copy. I'll check what version tonight.
Comment 3 John Layt 2008-12-02 22:06:51 UTC
Installed a printer and suddenly it all works again, as suspected seeing as the assert was checking to see the number of printers in the list was >= 0.  There must be some issue with the initialisation sequence of the dialog, as there should be at least the 'Print to PDF' and 'Print to PS' options there by that stage.

Hmmm.

Qt 4.4.3 from openSUSE packages works fine.  Qt 4.4.3 newly downloaded and self compiled falls over.  qt-copy (4.4.3 as well?) falls over.  So what's different about openSUSE (and probably every other distro packages)?
Comment 4 David Faure 2008-12-12 17:20:36 UTC
I think this is Thomas' code.
Comment 5 John Layt 2008-12-13 16:59:35 UTC
Raised in Qt Task Tracker, awaiting response.

See also bug http://bugs.kde.org/show_bug.cgi?id=177544 where the dialog doesn't crash but the file name line edit is not enabled, which is what I get using the openSuse packages for 4.4.3, as opposed to the crash which I get when running qt-copy.
Comment 6 Thomas Zander 2008-12-13 20:45:58 UTC
Looks very similar to http://trolltech.com/developer/task-tracker/index_html?method=entry&id=228614

hunk src/gui/dialogs/qprintdialog_unix.cpp 705
-    Q_ASSERT(index >= 0);
+    if (index < 0)
+        return;
Comment 7 John Layt 2008-12-14 15:00:01 UTC
Thomas is correct, must have missed that one when looking in the tracker.  Fix is scheduled for Qt 4.4.4.  I guess openSUSE must have backported it in their binary packages.