Bug 261529 - Ktorrent crash when moving data from one partition to the another
Summary: Ktorrent crash when moving data from one partition to the another
Status: RESOLVED FIXED
Alias: None
Product: ktorrent
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR crash
Target Milestone: ---
Assignee: Joris Guisson
URL:
Keywords:
: 262560 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-12-29 13:06 UTC by Dave Plater
Modified: 2011-01-15 17:02 UTC (History)
0 users

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


Attachments
As requested (2.44 KB, text/plain)
2011-01-13 20:54 UTC, Dave Plater
Details
ktorrent log tail when using valgrind (489.67 KB, text/plain)
2011-01-13 21:01 UTC, Dave Plater
Details
I plead sleep deprivation. (253.07 KB, text/x-log)
2011-01-14 19:16 UTC, Dave Plater
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Plater 2010-12-29 13:06:38 UTC
Application: ktorrent (4.1dev)
KDE Platform Version: 4.5.90 (4.6 RC1)
Qt Version: 4.7.1
Operating System: Linux 2.6.34.7-0.5-desktop x86_64
Distribution: "openSUSE 11.3 (x86_64)"

-- Information about the crash:
- What I was doing when the application crashed:
I had selected a completed download that was in the process of seeding and right clicked on settings, I unchecked the box for move to $HOME/images when complete and the crash occurred. The data wasn't moved to /data/davepl/dvd which is another partition and I had to move it via the move data context menu item.

-- Backtrace:
Application: KTorrent (ktorrent), signal: Segmentation fault
[Current thread is 1 (Thread 0x7f19d97cf760 (LWP 6083))]

Thread 7 (Thread 0x7f19c5883710 (LWP 6113)):
#0  0x00007f19d567cbc2 in __libc_disable_asynccancel () from /lib64/libc.so.6
#1  0x00007f19d56666c7 in poll () from /lib64/libc.so.6
#2  0x00007f19d09c5fd4 in ?? () from /usr/lib64/libglib-2.0.so.0
#3  0x00007f19d09c6510 in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#4  0x00007f19d70c9ae6 in QEventDispatcherGlib::processEvents (this=0x856d20, flags=<value optimized out>) at kernel/qeventdispatcher_glib.cpp:424
#5  0x00007f19d709e262 in QEventLoop::processEvents (this=<value optimized out>, flags=...) at kernel/qeventloop.cpp:149
#6  0x00007f19d709e475 in QEventLoop::exec (this=0x7f19c5882e20, flags=...) at kernel/qeventloop.cpp:201
#7  0x00007f19d6fb11a4 in QThread::exec (this=<value optimized out>) at thread/qthread.cpp:490
#8  0x00007f19d6fb3a1e in QThreadPrivate::start (arg=0x808a00) at thread/qthread_unix.cpp:285
#9  0x00007f19d6d24a4f in start_thread () from /lib64/libpthread.so.0
#10 0x00007f19d566f82d in clone () from /lib64/libc.so.6
#11 0x0000000000000000 in ?? ()

Thread 6 (Thread 0x7f19bd0da710 (LWP 6347)):
#0  0x00007f19d6d29709 in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00007f19d6fb37d5 in thread_sleep (ti=0x7f19bd0d9db0) at thread/qthread_unix.cpp:435
#2  0x00007f19d6fb3940 in QThread::msleep (msecs=<value optimized out>) at thread/qthread_unix.cpp:461
#3  0x00007f19d9304d38 in net::DownloadThread::update (this=0x6e9af0) at /usr/src/debug/libktorrent/src/net/downloadthread.cpp:91
#4  0x00007f19d9304d99 in net::NetworkThread::run (this=0x6e9af0) at /usr/src/debug/libktorrent/src/net/networkthread.cpp:48
#5  0x00007f19d6fb3a1e in QThreadPrivate::start (arg=0x6e9af0) at thread/qthread_unix.cpp:285
#6  0x00007f19d6d24a4f in start_thread () from /lib64/libpthread.so.0
#7  0x00007f19d566f82d in clone () from /lib64/libc.so.6
#8  0x0000000000000000 in ?? ()

Thread 5 (Thread 0x7f19bc8d9710 (LWP 6348)):
#0  0x00007f19d6d29709 in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00007f19d6fb37d5 in thread_sleep (ti=0x7f19bc8d8db0) at thread/qthread_unix.cpp:435
#2  0x00007f19d6fb3940 in QThread::msleep (msecs=<value optimized out>) at thread/qthread_unix.cpp:461
#3  0x00007f19d9304588 in net::UploadThread::update (this=0x6ea040) at /usr/src/debug/libktorrent/src/net/uploadthread.cpp:89
#4  0x00007f19d9304d99 in net::NetworkThread::run (this=0x6ea040) at /usr/src/debug/libktorrent/src/net/networkthread.cpp:48
#5  0x00007f19d6fb3a1e in QThreadPrivate::start (arg=0x6ea040) at thread/qthread_unix.cpp:285
#6  0x00007f19d6d24a4f in start_thread () from /lib64/libpthread.so.0
#7  0x00007f19d566f82d in clone () from /lib64/libc.so.6
#8  0x0000000000000000 in ?? ()

Thread 4 (Thread 0x7f19bc0d8710 (LWP 6349)):
#0  0x00007f19d6d2939c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00007f19d6fb410b in wait (this=<value optimized out>, mutex=0x11f8d90, time=18446744073709551615) at thread/qwaitcondition_unix.cpp:88
#2  QWaitCondition::wait (this=<value optimized out>, mutex=0x11f8d90, time=18446744073709551615) at thread/qwaitcondition_unix.cpp:160
#3  0x00007f19d9307952 in net::ReverseResolverThread::run (this=0x11f8d80) at /usr/src/debug/libktorrent/src/net/reverseresolver.cpp:123
#4  0x00007f19d6fb3a1e in QThreadPrivate::start (arg=0x11f8d80) at thread/qthread_unix.cpp:285
#5  0x00007f19d6d24a4f in start_thread () from /lib64/libpthread.so.0
#6  0x00007f19d566f82d in clone () from /lib64/libc.so.6
#7  0x0000000000000000 in ?? ()

Thread 3 (Thread 0x7f19ba4a0710 (LWP 19042)):
#0  idleTimerSourcePrepare (source=0x23ac990, timeout=0x7f19ba49fc4c) at kernel/qeventdispatcher_glib.cpp:206
#1  0x00007f19d09c4f7f in g_main_context_prepare () from /usr/lib64/libglib-2.0.so.0
#2  0x00007f19d09c5e69 in ?? () from /usr/lib64/libglib-2.0.so.0
#3  0x00007f19d09c6510 in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#4  0x00007f19d70c9ae6 in QEventDispatcherGlib::processEvents (this=0x23acca0, flags=<value optimized out>) at kernel/qeventdispatcher_glib.cpp:424
#5  0x00007f19d709e262 in QEventLoop::processEvents (this=<value optimized out>, flags=...) at kernel/qeventloop.cpp:149
#6  0x00007f19d709e475 in QEventLoop::exec (this=0x7f19ba49fde0, flags=...) at kernel/qeventloop.cpp:201
#7  0x00007f19d6fb11a4 in QThread::exec (this=<value optimized out>) at thread/qthread.cpp:490
#8  0x00007f19d707f918 in QInotifyFileSystemWatcherEngine::run (this=0x26094b0) at io/qfilesystemwatcher_inotify.cpp:248
#9  0x00007f19d6fb3a1e in QThreadPrivate::start (arg=0x26094b0) at thread/qthread_unix.cpp:285
#10 0x00007f19d6d24a4f in start_thread () from /lib64/libpthread.so.0
#11 0x00007f19d566f82d in clone () from /lib64/libc.so.6
#12 0x0000000000000000 in ?? ()

Thread 2 (Thread 0x7f19c6084710 (LWP 26679)):
#0  0x00007f19d9307f16 in size (this=<value optimized out>, fd=22, mode=net::Poll::INPUT) at /usr/include/c++/4.5/bits/stl_vector.h:534
#1  net::Poll::add (this=<value optimized out>, fd=22, mode=net::Poll::INPUT) at /usr/src/debug/libktorrent/src/net/poll.cpp:47
#2  0x00007f19d93012a4 in net::Socket::prepare (this=0x1b32c90, p=<value optimized out>, mode=<value optimized out>) at /usr/src/debug/libktorrent/src/net/socket.cpp:454
#3  0x00007f19d9369796 in dht::RPCServer::Private::run (this=0x1c42bc0) at /usr/src/debug/libktorrent/src/dht/rpcserver.cpp:92
#4  0x00007f19d6fb3a1e in QThreadPrivate::start (arg=0x1c42bc0) at thread/qthread_unix.cpp:285
#5  0x00007f19d6d24a4f in start_thread () from /lib64/libpthread.so.0
#6  0x00007f19d566f82d in clone () from /lib64/libc.so.6
#7  0x0000000000000000 in ?? ()

Thread 1 (Thread 0x7f19d97cf760 (LWP 6083)):
[KCrash Handler]
#6  0x00000000033f8b00 in ?? ()
#7  0x00007f19d9331d39 in bt::Downloader::downloadRate (this=0x176ddb0) at /usr/src/debug/libktorrent/src/download/downloader.cpp:523
#8  0x00007f19d934c10d in bt::TorrentControl::updateStats (this=0x1785e40) at /usr/src/debug/libktorrent/src/torrent/torrentcontrol.cpp:1237
#9  0x00007f19d934debd in bt::TorrentControl::update (this=0x1785e40) at /usr/src/debug/libktorrent/src/torrent/torrentcontrol.cpp:259
#10 0x000000000042e473 in kt::Core::update (this=0x899f30) at /usr/src/debug/ktorrent/ktorrent/core.cpp:1043
#11 0x0000000000435821 in kt::Core::qt_metacall (this=0x899f30, _c=QMetaObject::InvokeMetaMethod, _id=10, _a=0x7fff56279b50) at /usr/src/debug/ktorrent/build/ktorrent/core.moc:159
#12 0x00007f19d70b3fef in QMetaObject::activate (sender=0x899f58, m=<value optimized out>, local_signal_index=<value optimized out>, argv=0x0) at kernel/qobject.cpp:3272
#13 0x00007f19d70b2999 in QObject::event (this=0x899f58, e=<value optimized out>) at kernel/qobject.cpp:1175
#14 0x00007f19d623fcd4 in QApplicationPrivate::notify_helper (this=0x753330, receiver=0x899f58, e=0x7fff5627a2d0) at kernel/qapplication.cpp:4445
#15 0x00007f19d62481ca in QApplication::notify (this=<value optimized out>, receiver=0x899f58, e=0x7fff5627a2d0) at kernel/qapplication.cpp:4324
#16 0x000000000043c0b1 in kt::App::notify (this=<value optimized out>, receiver=<value optimized out>, event=<value optimized out>) at /usr/src/debug/ktorrent/ktorrent/app.cpp:97
#17 0x00007f19d709ee2c in QCoreApplication::notifyInternal (this=0x7fff5627a680, receiver=0x899f58, event=0x7fff5627a2d0) at kernel/qcoreapplication.cpp:732
#18 0x00007f19d70cc658 in sendEvent (this=0x744360) at kernel/qcoreapplication.h:215
#19 QTimerInfoList::activateTimers (this=0x744360) at kernel/qeventdispatcher_unix.cpp:618
#20 0x00007f19d70c93b4 in timerSourceDispatch (source=<value optimized out>) at kernel/qeventdispatcher_glib.cpp:184
#21 0x00007f19d09c5a93 in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
#22 0x00007f19d09c6270 in ?? () from /usr/lib64/libglib-2.0.so.0
#23 0x00007f19d09c6510 in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#24 0x00007f19d70c9a8f in QEventDispatcherGlib::processEvents (this=0x6e7820, flags=<value optimized out>) at kernel/qeventdispatcher_glib.cpp:422
#25 0x00007f19d62e4eae in QGuiEventDispatcherGlib::processEvents (this=<value optimized out>, flags=<value optimized out>) at kernel/qguieventdispatcher_glib.cpp:204
#26 0x00007f19d709e262 in QEventLoop::processEvents (this=<value optimized out>, flags=...) at kernel/qeventloop.cpp:149
#27 0x00007f19d709e475 in QEventLoop::exec (this=0x7fff5627a5e0, flags=...) at kernel/qeventloop.cpp:201
#28 0x00007f19d70a28db in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1009
#29 0x000000000042bce2 in main (argc=6, argv=0x7fff5627b4b8) at /usr/src/debug/ktorrent/ktorrent/main.cpp:176

Reported using DrKonqi
Comment 1 Joris Guisson 2011-01-09 14:51:29 UTC
*** Bug 262560 has been marked as a duplicate of this bug. ***
Comment 2 Joris Guisson 2011-01-09 16:55:56 UTC
Would it be possible to run ktorrent under valgrind ?

valgrind --tool=memcheck --num-callers=40 --log-file=vg.log /usr/bin/ktorrent --nofork

Run it until it crashes, then post the vg.log file here.

Note that, running under valgrind is slow.
Comment 3 Dave Plater 2011-01-13 20:54:46 UTC
Created attachment 55982 [details]
As requested

I've also noticed that the column headers for the peers display intermittently become greyed out and unusable, at the same time the right click context menu only shows a shadow of a box in the cell where the mouse pointer is and an empty almost collapsed rectangle where the kick/ban peer context menu should be.
Comment 4 Dave Plater 2011-01-13 21:01:03 UTC
Created attachment 55983 [details]
ktorrent log tail when using valgrind

Just in case it's useful, I tailed the ktorrent log almost from the start of valgrind (it gave me something to look at while ktorrent slowly started).
Another factor to take into consideration is that I was seeding a private torrent.
Comment 5 Dave Plater 2011-01-13 21:03:38 UTC
If you look at the ktorrent log, the end contains the same output as valgrind when the crash happened.
Comment 6 Dave Plater 2011-01-13 21:09:35 UTC
BTW I've just noticed that this bug is for the checking/unchecking "move when completed" box. This no longer causes a crash only the superseeding check box.
Comment 7 Dave Plater 2011-01-13 22:11:05 UTC
One more comment : The right click individual torrent box originally had a greyed out "Use dht to get more peers" and "Use peer exchange to get more peers" check boxes. I've just noticed that they have also come to the foreground and are usable.

Ok I've just confirmed that the crash only happens with private torrents from :
http://www.scenetime.com/ and  http://thebox.bz which are the only private torrent sites I use. I can check/uncheck the superseeding box with public torrents with no ill effects, also the individual dht and peer exchange check boxes work with public torrents but not with the private ones. The problem with the intermittent column geaders in peers display is most probably also isolated to private torrents as I haven't noticed it in public ones but I can't confirm.
Comment 8 Joris Guisson 2011-01-14 18:23:45 UTC
And the vg.log file ?
Comment 9 Dave Plater 2011-01-14 19:16:49 UTC
Created attachment 56016 [details]
I plead sleep deprivation.
Comment 10 Dave Plater 2011-01-15 10:26:56 UTC
This bug is for ktorrent-4.1beta1 and libktorrent-1.1beta1
Comment 11 Joris Guisson 2011-01-15 12:09:30 UTC
commit d467159e12b408d6713ee618a6ec895ff9f936ee
branch master
Author: Joris <joris.guisson@gmail.com>
Date:   Fri Jan 14 21:19:37 2011 +0100

    Fix crash due to not properly cleaning up peers and everything related when switching to superseeding mode.
    
    BUG: 261529

diff --git a/ChangeLog b/ChangeLog
index c85fc6b..1b3604f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,7 @@ Changes in 1.1rc1:
 - Fix crash due to manipulating timers in the wrong thread (261903)
 - Fix compiler warning in TimeEstimator (262618)
 - Fix crash due to cleaning up timer in the wrong thread (260712)
+ - Fix crash due to not properly cleaning up Peers and everything related when switching to superseeding mode (261529)
 
 Changes in 1.1beta1:
 - Use UTF-8 as default codec in bt::Value::toString
diff --git a/src/peer/peermanager.cpp b/src/peer/peermanager.cpp
index fd5084d..42a2138 100644
--- a/src/peer/peermanager.cpp
+++ b/src/peer/peermanager.cpp
@@ -430,6 +430,8 @@ namespace bt
 			delete d->superseeder;
 			d->superseeder = 0;
 		}
+		
+		closeAllConnections();
 	}
 
 	Peer* PeerManager::findPeer(Uint32 peer_id)
@@ -548,6 +550,7 @@ namespace bt
 	
 	void PeerManager::setSuperSeeding(bool on,const BitSet & chunks)
 	{
+		Q_UNUSED(chunks);
 		if ((d->superseeder && on) || (!d->superseeder && !on))
 			return;
 		
@@ -571,9 +574,8 @@ namespace bt
 			pp.port = addr.port();
 			pp.local = false;
 			d->potential_peers.insert(std::make_pair(pp.ip,pp));
+			p->kill();
 		}
-		
-		closeAllConnections();
 	}
 	
 	void PeerManager::allowChunk(PeerInterface* peer, Uint32 chunk)
diff --git a/src/torrent/torrentcontrol.cpp b/src/torrent/torrentcontrol.cpp
index 28368d3..fbb1378 100644
--- a/src/torrent/torrentcontrol.cpp
+++ b/src/torrent/torrentcontrol.cpp
@@ -496,8 +496,6 @@ namespace bt
 		
 		pman->savePeerList(tordir + "peer_list");
 		pman->stop();
-		pman->closeAllConnections();
-		pman->clearDeadPeers();
 		cman->stop();
 		
 		stats.running = false;
Comment 12 Joris Guisson 2011-01-15 12:12:26 UTC
commit ec3824566b0183233d90e29a281f172d6d2afe6f
branch 1.1
Author: Joris <joris.guisson@gmail.com>
Date:   Fri Jan 14 21:19:37 2011 +0100

    Merge to 1.1: Fix crash due to not properly cleaning up peers and everything related when switching to superseeding mode.
    
    CCBUG: 261529

diff --git a/ChangeLog b/ChangeLog
index cebc1cc..90ed190 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@ Changes in 1.1rc1:
 - Fix crash due to manipulating timers in the wrong thread (261903)
 - Fix compiler warning in TimeEstimator (262618)
 - Fix crash due to cleaning up timer in the wrong thread (260712)
+ - Fix crash due to not properly cleaning up Peers and everything related when switching to superseeding mode (261529)
 
 Changes in 1.1beta1:
 - Use UTF-8 as default codec in bt::Value::toString
diff --git a/src/peer/peermanager.cpp b/src/peer/peermanager.cpp
index fd5084d..42a2138 100644
--- a/src/peer/peermanager.cpp
+++ b/src/peer/peermanager.cpp
@@ -430,6 +430,8 @@ namespace bt
 			delete d->superseeder;
 			d->superseeder = 0;
 		}
+		
+		closeAllConnections();
 	}
 
 	Peer* PeerManager::findPeer(Uint32 peer_id)
@@ -548,6 +550,7 @@ namespace bt
 	
 	void PeerManager::setSuperSeeding(bool on,const BitSet & chunks)
 	{
+		Q_UNUSED(chunks);
 		if ((d->superseeder && on) || (!d->superseeder && !on))
 			return;
 		
@@ -571,9 +574,8 @@ namespace bt
 			pp.port = addr.port();
 			pp.local = false;
 			d->potential_peers.insert(std::make_pair(pp.ip,pp));
+			p->kill();
 		}
-		
-		closeAllConnections();
 	}
 	
 	void PeerManager::allowChunk(PeerInterface* peer, Uint32 chunk)
diff --git a/src/torrent/torrentcontrol.cpp b/src/torrent/torrentcontrol.cpp
index 36748b6..72981d6 100644
--- a/src/torrent/torrentcontrol.cpp
+++ b/src/torrent/torrentcontrol.cpp
@@ -496,8 +496,6 @@ namespace bt
 		
 		pman->savePeerList(tordir + "peer_list");
 		pman->stop();
-		pman->closeAllConnections();
-		pman->clearDeadPeers();
 		cman->stop();
 		
 		stats.running = false;
Comment 13 Dave Plater 2011-01-15 17:02:56 UTC
Confirm patched libktorrent works and submitted to openSUSE KDE:Factory:Desktop