Bug 148155 - Ktorrent 2.2.1 Crash on exit Sig 11
Summary: Ktorrent 2.2.1 Crash on exit Sig 11
Status: RESOLVED FIXED
Alias: None
Product: ktorrent
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR crash
Target Milestone: ---
Assignee: Joris Guisson
URL:
Keywords:
: 148345 148662 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-07-24 04:55 UTC by John Aylward
Modified: 2007-08-09 08:40 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Aylward 2007-07-24 04:55:11 UTC
Version:           2.2.1 (using KDE KDE 3.5.7)
Installed from:    Gentoo Packages
Compiler:          gcc-4.1.2 
OS:                Linux

Plugins loaded:
Info Widget
Statistics
UPnP

(no debugging symbols found)
Using host libthread_db library "/lib/libthread_db.so.1".
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
[New Thread 47087060224560 (LWP 2049)]
[KCrash handler]
#5  0x0000000000000000 in ?? ()
#6  0x00002ad34ae12a4d in kt::PluginManager::unloadAll ()
   from /usr/lib64/libktorrent-2.2.1.so
#7  0x00000000004640a8 in ?? ()
#8  0x00002ad34b8f636d in KMainWindow::shuttingDown ()
   from /usr/kde/3.5/lib64/libkdeui.so.4
#9  0x00002ad34ba2522d in KMainWindow::qt_invoke ()
   from /usr/kde/3.5/lib64/libkdeui.so.4
#10 0x00002ad34b1ae93e in KParts::MainWindow::qt_invoke ()
   from /usr/kde/3.5/lib64/libkparts.so.2
#11 0x00000000004788ad in ?? ()
#12 0x00000000004684f1 in ?? ()
#13 0x00002ad34ccbb5bc in QObject::activate_signal ()
   from /usr/qt/3/lib64/libqt-mt.so.3
#14 0x00002ad34ccbc263 in QObject::activate_signal ()
   from /usr/qt/3/lib64/libqt-mt.so.3
#15 0x00002ad34bf05eb2 in KApplication::qt_emit ()
   from /usr/kde/3.5/lib64/libkdecore.so.4
#16 0x00002ad34bf05ed9 in KUniqueApplication::qt_emit ()
   from /usr/kde/3.5/lib64/libkdecore.so.4
#17 0x0000000000462d39 in ?? ()
#18 0x00002ad34ccbb573 in QObject::activate_signal ()
   from /usr/qt/3/lib64/libqt-mt.so.3
#19 0x00002ad34ccbc263 in QObject::activate_signal ()
   from /usr/qt/3/lib64/libqt-mt.so.3
#20 0x00002ad34cc79772 in QEventLoop::enterLoop ()
   from /usr/qt/3/lib64/libqt-mt.so.3
#21 0x00002ad34cc795a2 in QEventLoop::exec ()
   from /usr/qt/3/lib64/libqt-mt.so.3
#22 0x00000000004632e2 in ?? ()
#23 0x00002ad34f5d7374 in __libc_start_main () from /lib/libc.so.6
#24 0x000000000042eb59 in ?? ()
#25 0x00007fff5fe9ab18 in ?? ()
#26 0x0000000000000000 in ?? ()
Comment 1 John Aylward 2007-07-24 04:59:47 UTC
I am able to load and unload the plugins fine withing ktorrent.

I tested each of the plugins I had loaded, and the one that segfaults on exit is the UPnP one.

It's probably related to the fix to close the ports on the router.
Comment 2 Joris Guisson 2007-07-24 11:23:25 UTC
Can't reproduce it, can you compile with debug enabled (./configure --enable-debug=full) ?
Comment 3 John Aylward 2007-07-24 15:34:59 UTC
The backtrace is with debug full enabled. is there another tool I can use to get you more information other than the one built into KDE?
Comment 4 John Aylward 2007-07-24 15:44:26 UTC
I found some info on using gdb here are the results:

(the "Program exited normally." message was passed just after ktorrent stared up, not on shutdown)

gdb `which ktorrent`
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu"...
(no debugging symbols found)
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) run
Starting program: /usr/bin/ktorrent
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
---Type <return> to continue, or q <return> to quit---
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
[New Thread 47119247346224 (LWP 18084)]
kbuildsycoca running...
kdevelop (core): [virtual void DDockWindow::addWidget(const QString&, QWidget*, bool)]
kdevelop (core): [virtual void DDockWindow::addWidget(const QString&, QWidget*, bool)]
kdevelop (core): [virtual void DDockWindow::addWidget(const QString&, QWidget*, bool)]
kdevelop (core): [virtual void DDockWindow::addWidget(const QString&, QWidget*, bool)]
kdevelop (core): [virtual void DDockWindow::addWidget(const QString&, QWidget*, bool)]
kdevelop (core): [virtual void DDockWindow::addWidget(const QString&, QWidget*, bool)]

Program exited normally.
(gdb) kdevelop (core): [virtual void DDockWindow::removeWidget(QWidget*)]
kdevelop (core): [virtual void DDockWindow::removeWidget(QWidget*)]
kdevelop (core): [virtual void DDockWindow::removeWidget(QWidget*)]
kdevelop (core): [virtual void DDockWindow::removeWidget(QWidget*)]
kdevelop (core): [virtual void DDockWindow::removeWidget(QWidget*)]
ICE default IO error handler doing an exit(), pid = 18100, errno = 0
Comment 5 John Aylward 2007-07-24 15:47:18 UTC
oops, I didn't run it with the UPnP plugin installed, sorry about that, here is the result with the plugin running on exit


gdb `which ktorrent`
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu"...
(no debugging symbols found)
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) run --nofork
Starting program: /usr/bin/ktorrent --nofork
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
---Type <return> to continue, or q <return> to quit---
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
[New Thread 47020804188720 (LWP 18115)]
kbuildsycoca running...
kdevelop (core): [virtual void DDockWindow::addWidget(const QString&, QWidget*, bool)]
kdevelop (core): [virtual void DDockWindow::addWidget(const QString&, QWidget*, bool)]
kdevelop (core): [virtual void DDockWindow::addWidget(const QString&, QWidget*, bool)]
kdevelop (core): [virtual void DDockWindow::addWidget(const QString&, QWidget*, bool)]
kdevelop (core): [virtual void DDockWindow::addWidget(const QString&, QWidget*, bool)]
kdevelop (core): [virtual void DDockWindow::addWidget(const QString&, QWidget*, bool)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 47020804188720 (LWP 18115)]
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00002ac3ddb64a4d in kt::PluginManager::unloadAll () from /usr/lib64/libktorrent-2.2.1.so
#2  0x00000000004640a8 in ?? ()
#3  0x00002ac3de64836d in KMainWindow::shuttingDown () from /usr/kde/3.5/lib64/libkdeui.so.4
#4  0x00002ac3de77722d in KMainWindow::qt_invoke () from /usr/kde/3.5/lib64/libkdeui.so.4
#5  0x00002ac3ddf0093e in KParts::MainWindow::qt_invoke () from /usr/kde/3.5/lib64/libkparts.so.2
#6  0x00000000004788ad in ?? ()
#7  0x00000000004684f1 in ?? ()
#8  0x00002ac3dfa0d5bc in QObject::activate_signal () from /usr/qt/3/lib64/libqt-mt.so.3
#9  0x00002ac3dfa0e263 in QObject::activate_signal () from /usr/qt/3/lib64/libqt-mt.so.3
#10 0x00002ac3dec57eb2 in KApplication::qt_emit () from /usr/kde/3.5/lib64/libkdecore.so.4
#11 0x00002ac3dec57ed9 in KUniqueApplication::qt_emit () from /usr/kde/3.5/lib64/libkdecore.so.4
#12 0x0000000000462d39 in ?? ()
#13 0x00002ac3dfa0d573 in QObject::activate_signal () from /usr/qt/3/lib64/libqt-mt.so.3
#14 0x00002ac3dfa0e263 in QObject::activate_signal () from /usr/qt/3/lib64/libqt-mt.so.3
#15 0x00002ac3df9cb772 in QEventLoop::enterLoop () from /usr/qt/3/lib64/libqt-mt.so.3
#16 0x00002ac3df9cb5a2 in QEventLoop::exec () from /usr/qt/3/lib64/libqt-mt.so.3
#17 0x00000000004632e2 in ?? ()
#18 0x00002ac3e2329374 in __libc_start_main () from /lib/libc.so.6
#19 0x000000000042eb59 in ?? ()
#20 0x00007fffcd147f78 in ?? ()
#21 0x0000000000000000 in ?? ()
Comment 6 John Aylward 2007-07-24 15:54:25 UTC
here is my configure line (from the gentoo package):

./configure --prefix=/usr --host=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --enable-knetwork --with-x --enable-mitshm --with-xinerama --with-qt-dir=/usr/qt/3 --enable-mt --with-qt-libraries=/usr/qt/3/lib64 --disable-dependency-tracking --enable-debug=full --with-debug --enable-final --with-arts --enable-libsuffix=64 --with-extra-includes=/usr/kde/3.5/include --with-extra-libs=/usr/kde/3.5/lib64 --libdir=/usr/lib64 --build=x86_64-pc-linux-gnu
Comment 7 Joris Guisson 2007-07-24 18:22:52 UTC
Could you add --enable-debug=full to those options, with this we actually get the  file and line where this crash is.
Comment 8 John Aylward 2007-07-24 19:08:55 UTC
it's already there, that's why I'm not sure what you mean it's right after  --disable-dependency-tracking and before  --with-debug --enable-final
Comment 9 Bram Schoenmakers 2007-07-24 19:37:19 UTC
Not --with-debug, but --enable-debug=full

See also http://techbase.kde.org/Development/Tutorials/Debugging/How_to_create_useful_crash_reports
Comment 10 John Aylward 2007-07-24 20:39:40 UTC
So are you saying I should have then --enable-debug=full and NOT have the --with-debug? does the --with-debug flag change how the --enable-debug=full flag works?  If you actually look at the configure line I provided you'll see that both are present. If that's a problem then let me know, but I don't see how it is. Either way I'm not getting lines numbers.

just for fun, here's an example of one of the ktorrent files being compiled:

/bin/sh ../../libtool --silent --tag=CXX --mode=compile x86_64-pc-linux-gnu-g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../apps/ktorrent -I./../../libktorrent -I/usr/kde/3.5/include -I/usr/qt/3/include -I.  -I/usr/kde/3.5/include  -DQT_THREAD_SUPPORT  -D_REENTRANT  -Wno-long-long -Wundef -ansi -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -fno-builtin -g3 -fno-inline -march=athlon64 -O1 -pipe -msse3 -ggdb -Wformat-security -Wmissing-format-attribute -Wno-non-virtual-dtor -fno-exceptions -fno-check-new -fno-common -fexceptions  -c -o ktpartfileimportplugin_la.all_cpp.lo ktpartfileimportplugin_la.all_cpp.cpp


All the debugging options are there (-g3 and -ggdb)
Comment 11 John Aylward 2007-07-24 21:03:22 UTC
OK, the problem was that Gentoo was stripping the libs, I found a doc on how to disable that, and now here is a proper backtrace :)

Using host libthread_db library "/lib/libthread_db.so.1".
[Thread debugging using libthread_db enabled]
[New Thread 47373883050544 (LWP 3649)]
[KCrash handler]
#5  0x0000000000000000 in ?? ()
#6  0x00002b1612da6b66 in kt::PluginManager::unloadAll (this=0x9c0360, 
    save=false) at pluginmanager.cpp:184
#7  0x0000000000466063 in KTorrentCore::onExit (this=0x9bedf0)
    at ktorrentcore.cpp:603
#8  0x0000000000469100 in KTorrent::queryExit (this=0x739cc0)
    at ktorrent.cpp:587
#9  0x00002b161388636d in KMainWindow::shuttingDown ()
   from /usr/kde/3.5/lib64/libkdeui.so.4
#10 0x00002b16139b522d in KMainWindow::qt_invoke ()
   from /usr/kde/3.5/lib64/libkdeui.so.4
#11 0x00002b161313e93e in KParts::MainWindow::qt_invoke ()
   from /usr/kde/3.5/lib64/libkparts.so.2
#12 0x000000000047cd3b in DMainWindow::qt_invoke (this=0x739cc0, _id=71, 
    _o=0x7fff97f07710) at dmainwindow.moc:138
#13 0x000000000046e012 in KTorrent::qt_invoke (this=0x739cc0, _id=71, 
    _o=0x7fff97f07710) at ktorrent.moc:220
#14 0x00002b1614c4b5bc in QObject::activate_signal ()
   from /usr/qt/3/lib64/libqt-mt.so.3
#15 0x00002b1614c4c263 in QObject::activate_signal ()
   from /usr/qt/3/lib64/libqt-mt.so.3
#16 0x00002b1613e95eb2 in KApplication::qt_emit ()
   from /usr/kde/3.5/lib64/libkdecore.so.4
#17 0x00002b1613e95ed9 in KUniqueApplication::qt_emit ()
   from /usr/kde/3.5/lib64/libkdecore.so.4
#18 0x0000000000467cab in KTorrentApp::qt_emit (this=0xb48100, _id=0, _o=0x51)
    at ktorrentapp.moc:82
#19 0x00002b1614c4b573 in QObject::activate_signal ()
   from /usr/qt/3/lib64/libqt-mt.so.3
#20 0x00002b1614c4c263 in QObject::activate_signal ()
   from /usr/qt/3/lib64/libqt-mt.so.3
#21 0x00002b1614c09772 in QEventLoop::enterLoop ()
   from /usr/qt/3/lib64/libqt-mt.so.3
#22 0x00002b1614c095a2 in QEventLoop::exec ()
   from /usr/qt/3/lib64/libqt-mt.so.3
#23 0x00000000004682dd in main (argc=7, argv=0x7fff97f07b98) at main.cpp:179
Comment 12 Joris Guisson 2007-07-25 10:40:57 UTC
That's interesting, it crashes when we delete the WaitJob. 
Comment 13 Joris Guisson 2007-07-25 10:55:33 UTC
SVN commit 692284 by guisson:

Fix crash at exit caused by deleting a WaitJob, which was already deleted by itself. 

BUG: 148155



 M  +0 -2      apps/ktorrent/ktorrentcore.cpp  
 M  +6 -2      libktorrent/pluginmanager.cpp  


--- branches/extragear/kde3/network/ktorrent/apps/ktorrent/ktorrentcore.cpp #692283:692284
@@ -593,9 +593,7 @@
 	qman->onExit(job);
 	// wait for completion of stopped events
 	if (job->needToWait())
-	{
 		WaitJob::execute(job);
-	}
 	else
 		delete job;
 	
--- branches/extragear/kde3/network/ktorrent/libktorrent/pluginmanager.cpp #692283:692284
@@ -125,12 +125,14 @@
 			p->shutdown(wjob);
 			if (wjob->needToWait())
 				bt::WaitJob::execute(wjob);
+			else
+				delete wjob;
 		}
 		catch (Error & err)
 		{
 			Out(SYS_GEN|LOG_NOTICE) << "Error when unloading plugin: " << err.toString() << endl;
 		}
-		delete wjob;
+		
 
 		gui->removePluginGui(p);
 		p->unload();
@@ -174,14 +176,16 @@
 				p->shutdown(wjob);
 				i++;
 			}
+			
 			if (wjob->needToWait())
 				bt::WaitJob::execute(wjob);
+			else
+				delete wjob;
 		}
 		catch (Error & err)
 		{
 			Out(SYS_GEN|LOG_NOTICE) << "Error when unloading all plugins: " << err.toString() << endl;
 		}
-		delete wjob;
 		
 		// then unload them
 		bt::PtrMap<QString,Plugin>::iterator i = plugins.begin();
Comment 14 John Aylward 2007-07-25 20:31:03 UTC
Wouldn't the proper way to handle the delete to do it in the function that called the new, instead of in the execute method? I haven't done c++ work in a long time, but I thought a function isn't supposed to delete something it didn't create.
Comment 15 Joris Guisson 2007-07-26 10:27:06 UTC
KIO::Job's call deleteLater in their emitResult function, when the WaitJob is executed emitResult will get called, so there is no need to delete it manually. 

When the WaitJob is not executed we must delete it, because we never get to emitResult so the job does not commit suicide.

Wether or not this is proper, is a different debate, but that is the way KIO::Job's work.

Comment 16 Bram Schoenmakers 2007-07-30 08:23:43 UTC
*** Bug 148345 has been marked as a duplicate of this bug. ***
Comment 17 Bram Schoenmakers 2007-08-09 08:40:32 UTC
*** Bug 148662 has been marked as a duplicate of this bug. ***