Bug 58904 - print preview crashes kghostview
Summary: print preview crashes kghostview
Status: RESOLVED FIXED
Alias: None
Product: kghostview
Classification: Unmaintained
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: Wilco Greven
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-05-24 22:06 UTC by virgilg
Modified: 2003-09-10 13:47 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description virgilg 2003-05-24 22:06:57 UTC
Version:           0.13.2 (using KDE 3.1.2)
Installed from:    compiled sources
Compiler:          gcc version 2.95.3 20010315 (release)
OS:          Linux (i586) release 2.4.21-pre6

Hello,

The steps to reproduce the bug are as follows:
1) Open kghostview and load a PDF file.
2) Pretend to print the file. When the print dialog appears, check [x] preview. Click print.
3) When the print preview window appears, click "Cancel"
4) Print preview is closed
5) Repeat step 2 again.
6) kghostview will crash when print preview is to be displayed.

Best regards,
Virgil
Comment 1 Luís Pedro Coelho 2003-06-04 15:15:20 UTC
I cannot see this. Maybe any answers to the questions below would help: 
 
Does this happen with every file? Just PDF? PDF & PS? 
 
Do you have to print to a printer or does print to PS suffice? 
 
Do you get a backtrace? 
 
thank you, 
luis 
Comment 2 virgilg 2003-06-04 23:45:57 UTC
Luis, 
 
There's an omission in the steps to reproduce the bug: In-between steps 4 and 5 
minimise the KGhost window and restore it again. I believe this change appeared only 
after I upgraded to cups 1.1.19 and AFPL Ghostscript 8.00. Before it was enough to do 
the steps I described above. 
 
> Does this happen with every file? Just PDF? PDF & PS? 
It happens with both PDF and PS. 
 
>Do you have to print to a printer or does print to PS suffice? 
I print to a LPT connected Epson Stylus 800. 
 
>Do you get a backtrace? 
Here I can't get a backtrace because I don't have gdb installed on this machine. I also 
didn't compile kghost with --debug. I'll try to reproduce the bug on a different machine. 
 
Virgil 
Comment 3 Luís Pedro Coelho 2003-06-06 18:21:55 UTC
Confirming in BRAHCN. I cannot seem to get HEAD to crash but it doezs go into a 
funny state (no response). Below is the backtrace from BRANCH: 
 
[New Thread 16384 (LWP 32243)] 
0x411d47f7 in waitpid () from /lib/i686/libpthread.so.0 
#0  0x411d47f7 in waitpid () from /lib/i686/libpthread.so.0 
#1  0x4086695c in KCrash::defaultCrashHandler(int) () 
   from /opt/kde-cvs/lib/libkdecore.so.4 
#2  0x411d374e in __pthread_sighandler () from /lib/i686/libpthread.so.0 
#3  <signal handler called> 
#4  0x40b999a6 in QShared::ref() (this=0xbfffdfe0) at ../include/qshared.h:49 
#5  0x40ed6d8f in QGArray (this=0xbfffdfe0, a=@0x80c87b8) 
    at tools/qgarray.cpp:162 
#6  0x4087c47c in KInstance::instanceName() const () 
   from /opt/kde-cvs/lib/libkdecore.so.4 
#7  0x4067059a in KXMLGUIClient::setXMLFile(QString const&, bool, bool) () 
   from /opt/kde-cvs/lib/libkdeui.so.4 
#8  0x4005b44c in KGVPart (this=0x807df18, parentWidget=0xfffffe00,  
    parent=0xfffffe00, name=0xfffffe00 <Address 0xfffffe00 out of bounds>,  
    args=@0xfffffe00) at kgv_view.cpp:234 
#9  0x4005f0aa in KParts::GenericFactory<KGVPart>::createPartObject(QWidget*, 
char const*, QObject*, char const*, char const*, QStringList const&) ( 
    this=0x81d6b70, parentWidget=0xfffffe00,  
    widgetName=0xfffffe00 <Address 0xfffffe00 out of bounds>,  
    parent=0xfffffe00, name=0xfffffe00 <Address 0xfffffe00 out of bounds>,  
    className=0x40129f1e "KParts::ReadOnlyPart", args=@0xfffffe00) 
    at /opt/kde-cvs/include/kgenericfactory.tcc:145 
#10 0x4016f23f in KParts::Factory::createPart(QWidget*, char const*, QObject*, 
char const*, char const*, QStringList const&) () 
   from /opt/kde-cvs/lib/libkparts.so.2 
#11 0x4016f2c4 in KParts::Factory::createObject(QObject*, char const*, char 
const*, QStringList const&) () from /opt/kde-cvs/lib/libkparts.so.2 
#12 0x4087f161 in KLibFactory::create(QObject*, char const*, char const*, 
QStringList const&) () from /opt/kde-cvs/lib/libkdecore.so.4 
#13 0x400d040b in KPrintPreview::initView(KLibFactory*) () 
   from /opt/kde-cvs/lib/libkdeprint.so.4 
#14 0x400d14ea in KPrintPreview::preview(QString const&, bool, unsigned long) 
    () from /opt/kde-cvs/lib/libkdeprint.so.4 
#15 0x400dc66f in KPrinter::doPreview(QString const&) () 
   from /opt/kde-cvs/lib/libkdeprint.so.4 
#16 0x400dc19c in KPrinter::printFiles(QStringList const&, bool, bool) () 
   from /opt/kde-cvs/lib/libkdeprint.so.4 
#17 0x40047c68 in KGVMiniWidget::print() (this=0x80f9770) 
    at /opt/kde-cvs/src/qt-copy/include/qvaluelist.h:530 
#18 0x40049863 in KGVMiniWidget::qt_invoke(int, QUObject*) (this=0x80f9770,  
    _id=6, _o=0xbfffee00) at kgv_miniwidget.moc:189 
#19 0x40c56ae4 in QObject::activate_signal(QConnectionList*, QUObject*) ( 
    this=0x810a138, clist=0x8112fb8, o=0xbfffee00) at kernel/qobject.cpp:2226 
#20 0x40c569b7 in QObject::activate_signal(int) (this=0x810a138, signal=2) 
    at kernel/qobject.cpp:2200 
#21 0x405a21bb in KAction::activated() () from /opt/kde-cvs/lib/libkdeui.so.4 
#22 0x405a179f in KAction::slotActivated() () 
   from /opt/kde-cvs/lib/libkdeui.so.4 
#23 0x405a23b2 in KAction::qt_invoke(int, QUObject*) () 
   from /opt/kde-cvs/lib/libkdeui.so.4 
#24 0x40c56ae4 in QObject::activate_signal(QConnectionList*, QUObject*) ( 
    this=0x8120ee8, clist=0x821a8e0, o=0xbfffeef0) at kernel/qobject.cpp:2226 
#25 0x40c569b7 in QObject::activate_signal(int) (this=0x8120ee8, signal=2) 
    at kernel/qobject.cpp:2200 
#26 0x4085b16b in KAccelPrivate::menuItemActivated() () 
   from /opt/kde-cvs/lib/libkdecore.so.4 
#27 0x40857c49 in KAccelPrivate::eventFilter(QObject*, QEvent*) () 
   from /opt/kde-cvs/lib/libkdecore.so.4 
#28 0x40c54960 in QObject::activate_filters(QEvent*) (this=0x80b9028,  
    e=0xbffff2c0) at kernel/qobject.cpp:835 
#29 0x40c547d2 in QObject::event(QEvent*) (this=0x80b9028, e=0xbffff2c0) 
    at kernel/qobject.cpp:668 
#30 0x40c8d180 in QWidget::event(QEvent*) (this=0x80b9028, e=0xbffff2c0) 
    at kernel/qwidget.cpp:4327 
#31 0x40d3e5e1 in QMainWindow::event(QEvent*) (this=0x80b9028, e=0xbffff2c0) 
    at widgets/qmainwindow.cpp:1661 
#32 0x40bf2fe2 in QApplication::internalNotify(QObject*, QEvent*) ( 
    this=0xbffff6f0, receiver=0x80b9028, e=0xbffff2c0) 
    at kernel/qapplication.cpp:2363 
#33 0x40bf274e in QApplication::notify(QObject*, QEvent*) (this=0xbffff6f0,  
    receiver=0x80df4a0, e=0xbffff2c0) at kernel/qapplication.cpp:2155 
#34 0x407c5459 in KApplication::notify(QObject*, QEvent*) () 
   from /opt/kde-cvs/lib/libkdecore.so.4 
#35 0x408552e3 in KAccelEventHandler::x11Event(_XEvent*) () 
   from /opt/kde-cvs/lib/libkdecore.so.4 
#36 0x407ca62f in KApplication::x11EventFilter(_XEvent*) () 
   from /opt/kde-cvs/lib/libkdecore.so.4 
#37 0x40b86bf3 in qt_x11EventFilter (ev=0xbffff5b0) 
    at kernel/qapplication_x11.cpp:359 
#38 0x40b8f612 in QApplication::x11ProcessEvent(_XEvent*) (this=0xbffff6f0,  
    event=0xbffff5b0) at kernel/qapplication_x11.cpp:3216 
#39 0x40ba810b in QEventLoop::processEvents(unsigned) (this=0x8078938, 
flags=4) 
    at kernel/qeventloop_x11.cpp:186 
#40 0x40c0974a in QEventLoop::enterLoop() (this=0x8078938) 
    at kernel/qeventloop.cpp:198 
#41 0x40c09666 in QEventLoop::exec() (this=0x8078938) 
    at kernel/qeventloop.cpp:145 
#42 0x40bf315b in QApplication::exec() (this=0xbffff6f0) 
    at kernel/qapplication.cpp:2487 
#43 0x08048d4e in main (argc=0, argv=0x0) at main.cpp:56 
#44 0x420158f7 in __libc_start_main () from /lib/i686/libc.so.6 
 
 
 
Comment 4 Luís Pedro Coelho 2003-06-07 17:52:58 UTC
To reproduce in HEAD + BRANCH: cancel print preview, wait a couple of seconds 
(there is a timeout). Click on a menu or play around untill it crashes. 
 
It comes down to the following: 
 
kghostview is a simple main + shell dynamically linked to the part library. The main 
part is KGVPart. At run time, when the preview window gets called, the kghostview 
part is loaded, the corresponding factory object is constructed and the print thingy 
display its own postscript. When the preview is finished, the lib is unloaded and the 
factory destroyed. 
 
The problem is that destroying the factory, destroy KGVPart::s_instance which is still 
in use by the main application! This leads to crashes later. 
 
I do have a simple fix, but I will post on kde-core-devel since I am not sure whether 
this should be fixed like this. 
Comment 5 Luís Pedro Coelho 2003-06-07 19:38:52 UTC
Subject: kdegraphics/kghostview

CVS commit by luis_pedro: 

Fix bug 58904:

At run time, when a print preview window gets called, the same part is loaded (since
the print preview wants to display postscript as well) and the corresponding
factory object is constructed. When the preview is finished, the lib is
unloaded and the factory destroyed.

The problem is that destroying the factory, destroys  KGVFactory::s_instance
which is still in use by the main application! This leads to crashes later.

The solution here involves creating the part through a factory to increment the reference count.

This version of the patch is due to Simon Hausmann.

CCMAIL: 58904-done@bugs.kde.org


  M +3 -1      kgvshell.cpp   1.61


--- kdegraphics/kghostview/kgvshell.cpp  #1.60:1.61
@@ -37,4 +37,5 @@
 #include <klocale.h>
 #include <kpopupmenu.h>
+#include <kparts/componentfactory.h>
 
 #include <qcursor.h>
@@ -55,5 +56,6 @@ KGVShell::KGVShell() :
     _tmpFile( 0 )
 {
-    m_gvpart = new KGVPart( this, "kgvpart", this, "kgvpart" );
+    m_gvpart = KParts::ComponentFactory::createPartInstanceFromLibrary< KGVPart >( "libkghostviewpart", this, "kgvpart",
+                                                                                   this, "kgvpart" );
 
     /*---- File -----------------------------------------------------------*/


Comment 6 Alexander Patrakov 2003-07-30 06:37:09 UTC
To the person using AFPL Ghostscript with CUPS: this is not supposed to work at all since 
AFPL Ghostscript does not support generic raster "cups" device. Use only ESP Ghostscript 
or patched GNU Ghostscript  with CUPS. 
Comment 7 Stephan Leicht 2003-09-10 13:47:21 UTC
I still have the same crash. I use SuSE 8.2 with the latest updates 
(ghostscript-x11-7.05.6-23, cups-1.1.18-77) and KDE 3.1.3 SuSE8.2-RPMs 
(kdelibs3-3.1.3-61, kdegraphics3-3.1.3-13, kdegraphics3-postscript-3.1.3-70). 
Is this patch still missing in the latest SuSE-RPMs or isn't it resolved with 
this patch?