Bug 131142 - answering no when asked to recreate file crashes ktorrent consistenly
Summary: answering no when asked to recreate file crashes ktorrent consistenly
Status: RESOLVED FIXED
Alias: None
Product: ktorrent
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR crash
Target Milestone: ---
Assignee: Joris Guisson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-21 01:40 UTC by Niek Beernink
Modified: 2007-01-23 18:55 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
backtrace when answered "no" (5.06 KB, text/plain)
2006-07-21 01:41 UTC, Niek Beernink
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Niek Beernink 2006-07-21 01:40:47 UTC
Version:           2.0rc1 (using KDE KDE 3.5.3)
Installed from:    Ubuntu Packages

I'm using Ktorrent 2.0rc1, KDE 3.5.3, plugins loaded; infowidgetplugin, partfileimportplugin, schedulerplugin, searchplugin & upnpplugin.

How to reproduce:
1. Download a file. 
2. Remove file using anything but Ktorrent. (konqueror for example) 
3. Restart the Ktorrent. 
4. You get a dialog asking if you want to recreate the file. If answered "no" 
the application consistently crashes. (If answered yes, the file seems to be properly 
re-created.)

Expected Behavior:
Ktorrent removes the missing file from the list of downloads. (Or keeps it in the list, but doesn't recreate the file, and clicking start downloading would create the file?)

At first I thought it was related to #128567 but since that included the USB drive being missing and ktorrent doesn't need to write in order to crash, I figured I would file a bug about this.
Comment 1 Niek Beernink 2006-07-21 01:41:17 UTC
Created attachment 17051 [details]
backtrace when answered "no"
Comment 2 Joris Guisson 2006-07-21 10:20:46 UTC
SVN commit 564759 by guisson:

Made sure KT doesn't crash when Qt is not built with exception support.


BUG: 131142



 M  +15 -8     apps/ktorrent/ktorrentcore.cpp  
 M  +1 -1      apps/ktorrent/ktorrentcore.h  
 M  +5 -1      libktorrent/interfaces/torrentinterface.h  
 M  +9 -1      libktorrent/torrent/torrentcontrol.cpp  
 M  +1 -0      libktorrent/torrent/torrentcontrol.h  


--- trunk/extragear/network/ktorrent/apps/ktorrent/ktorrentcore.cpp #564758:564759
@@ -758,8 +758,10 @@
 	        tc->updateTracker();
 }
 
-void KTorrentCore::aboutToBeStarted(kt::TorrentInterface* tc)
+void KTorrentCore::aboutToBeStarted(kt::TorrentInterface* tc,bool & ret)
 {
+	ret = true;
+	
 	QStringList missing;
 	if (!tc->hasMissingFiles(missing))
 		return;
@@ -781,7 +783,8 @@
 			catch (bt::Error & e)
 			{
 				KMessageBox::error(0,i18n("Cannot recreate missing files : %1").arg(e.toString()));
-				throw Error(i18n("Data files are missing"));
+				tc->handleError(i18n("Data files are missing"));
+				ret = false;
 			}
 		}
 		else if (ret == KMessageBox::No)
@@ -794,12 +797,14 @@
 			catch (bt::Error & e)
 			{
 				KMessageBox::error(0,i18n("Cannot deselect missing files : %1").arg(e.toString()));
-				throw Error(i18n("Data files are missing"));
+				tc->handleError(i18n("Data files are missing"));
+				ret = false;
 			}
 		}
 		else
 		{
-			throw Error(i18n("Data files are missing"));
+			tc->handleError(i18n("Data files are missing"));
+			ret = false;
 		}
 	}
 	else
@@ -815,12 +820,14 @@
 			catch (bt::Error & e)
 			{
 				KMessageBox::error(0,i18n("Cannot recreate data file : %1").arg(e.toString()));
-				throw Error(i18n("Data file is missing"));
+				tc->handleError(i18n("Data file is missing"));
+				ret = false;
 			}
 		}
 		else
 		{
-			throw Error(i18n("Data file is missing"));
+			tc->handleError(i18n("Data file is missing"));
+			ret = false;
 		}
 	}
 	
@@ -834,8 +841,8 @@
 			this, SLOT(slotStoppedByError(kt::TorrentInterface*, QString )));
 	connect(tc, SIGNAL(seedingAutoStopped( kt::TorrentInterface* )),
 			this, SLOT(torrentSeedAutoStopped( kt::TorrentInterface* )));
-	connect(tc,SIGNAL(aboutToBeStarted( kt::TorrentInterface* )),
-			this, SLOT(aboutToBeStarted( kt::TorrentInterface* )));
+	connect(tc,SIGNAL(aboutToBeStarted( kt::TorrentInterface*,bool & )),
+			this, SLOT(aboutToBeStarted( kt::TorrentInterface*,bool & )));
 }
 
 #include "ktorrentcore.moc"
--- trunk/extragear/network/ktorrent/apps/ktorrent/ktorrentcore.h #564758:564759
@@ -252,7 +252,7 @@
 	 * A torrent is about to be started. We will do some file checks upon this signal.
 	 * @param tc The TorrentInterface
 	*/
-	void aboutToBeStarted(kt::TorrentInterface* tc);
+	void aboutToBeStarted(kt::TorrentInterface* tc,bool & ret);
 	
 signals:
 	/**
--- trunk/extragear/network/ktorrent/libktorrent/interfaces/torrentinterface.h #564758:564759
@@ -319,6 +319,9 @@
 		
 		///Checks if a seeding torrent has reached its maximum share ratio
 		virtual bool overMaxRatio() = 0;
+		
+		/// Handle an error
+		virtual void handleError(const QString & err) = 0;
 	signals:
 		/**
 		 * Emited when we have finished downloading.
@@ -350,8 +353,9 @@
 		 * Emitted just before the torrent is started, this should be used to do some
 		 * checks on the files in the cache.
 		 * @param me The torrent which emitted the signal
+		 * @param ret The return value
 		 */
-		void aboutToBeStarted(kt::TorrentInterface* me);
+		void aboutToBeStarted(kt::TorrentInterface* me,bool & ret);
 		
 		/**
 		 * Emitted when missing files have been marked as dnd.
--- trunk/extragear/network/ktorrent/libktorrent/torrent/torrentcontrol.cpp #564758:564759
@@ -264,7 +264,10 @@
 		io_error = false;
 		try
 		{
-			aboutToBeStarted(this);
+			bool ret = true;
+			aboutToBeStarted(this,ret);
+			if (!ret)
+				return;
 		}
 		catch (Error & err)
 		{
@@ -1198,6 +1201,11 @@
 		}
 	}
 	
+	void TorrentControl::handleError(const QString & err)
+	{
+		onIOError(err);
+	}
+	
 	Uint32 TorrentControl::getNumDHTNodes() const
 	{
 		return tor->getNumDHTNodes();
--- trunk/extragear/network/ktorrent/libktorrent/torrent/torrentcontrol.h #564758:564759
@@ -249,6 +249,7 @@
 		void getLeecherInfo(Uint32 & total,Uint32 & connected_to) const;
 		void migrateTorrent(const QString & default_save_dir);
 		void continueStart();
+		virtual void handleError(const QString & err);
 
 		
 	private:
Comment 3 CTWaley 2007-01-23 09:48:46 UTC
I, too, have this same problem with KT 2.1rc1 on KDE 3.5.4 (standard Slackware 11.0 KDE packages). I compiled KT from source with the following configure options:
CFLAGS="-O2 -march=i486 -mtune=i686" \ 
CXXFLAGS="-O2 -march=i486 -mtune=i686" \
./configure --prefix=/opt/kde --enable-torrent-mimetype \
            --with-gnu-ld i486-slackware-linux


It was working flawlessly until I moved a downloaded file to a different location. After logging out of KDE to the command line for a bit, then logged back in, I was asked if I wanted to recreate a file. I tried to cancel, but KT crashed right after that. I'm sorry, I didn't make a copy of the backtrace when it first happened.

After that point, every time I started KT, it would segfault with the Signal 11 (SIGSEGV) error.  I even removed the KT and reinstalled it, but it didn't make any difference.  So I finally made a backtrace from the crash handler dialog box.

After that, I downloaded an earlier version of KT, version 2.0.3, and compiled it with the same flags as above.  After installing it, KT 2.0.3 started up without any problem and asked the same thing about the missing file.  I cancelled it and no problem this time.

I could probably go back to the later version, now, but I haven't tried it.  I think I'll wait until more bugs are shaken out of version 2.1 before upgrading.

Here is the backtrace I saved from version 2.1rc1:
-----------------------------------------------------------------------------
(no debugging symbols found)
Using host libthread_db library "/lib/tls/libthread_db.so.1".
[Thread debugging using libthread_db enabled]
[New Thread -1242818848 (LWP 27106)]
[KCrash handler]
#5  0xb6709847 in raise () from /lib/tls/libc.so.6
#6  0xb670b0d9 in abort () from /lib/tls/libc.so.6
#7  0xb74c8ff3 in kdbgstream::flush () from /opt/kde/lib/libkdecore.so.4
#8  0x08076fc8 in endl ()
#9  0xb7a9d146 in KIO::Scheduler::_scheduleJob () from /opt/kde/lib/libkio.so.4
#10 0xb7e274b1 in bt::HTTPTracker::doRequest ()
   from /opt/kde/lib/libktorrent.so.0
#11 0xb7e27af0 in bt::HTTPTracker::start () from /opt/kde/lib/libktorrent.so.0
#12 0xb7e4ea32 in bt::PeerSourceManager::start ()
   from /opt/kde/lib/libktorrent.so.0
#13 0xb7e139f7 in bt::TorrentControl::continueStart ()
   from /opt/kde/lib/libktorrent.so.0
#14 0xb7e13d98 in bt::TorrentControl::start ()
   from /opt/kde/lib/libktorrent.so.0
#15 0xb7e440c5 in bt::QueueManager::startSafely ()
   from /opt/kde/lib/libktorrent.so.0
#16 0xb7e453f1 in bt::QueueManager::start () from /opt/kde/lib/libktorrent.so.0
#17 0xb7e455ed in bt::QueueManager::orderQueue ()
   from /opt/kde/lib/libktorrent.so.0
#18 0x0807eb49 in QListViewItem::removeItem ()
#19 0x080679e6 in QGList::count ()
#20 0x0808586d in QValueListPrivate<int>::at ()
#21 0xb757ac5e in KUniqueApplication::processDelayed ()
   from /opt/kde/lib/libkdecore.so.4
#22 0xb757ae3c in KUniqueApplication::qt_invoke ()
   from /opt/kde/lib/libkdecore.so.4
#23 0x0808546f in QValueListPrivate<int>::at ()
#24 0xb6ed2004 in QObject::activate_signal ()
   from /usr/lib/qt/lib/libqt-mt.so.3
#25 0xb7211bad in QSignal::signal () from /usr/lib/qt/lib/libqt-mt.so.3
#26 0xb6eeca61 in QSignal::activate () from /usr/lib/qt/lib/libqt-mt.so.3
#27 0xb6ef4563 in QSingleShotTimer::event () from /usr/lib/qt/lib/libqt-mt.so.3
#28 0xb6e6d46f in QApplication::internalNotify ()
   from /usr/lib/qt/lib/libqt-mt.so.3
#29 0xb6e6d60c in QApplication::notify () from /usr/lib/qt/lib/libqt-mt.so.3
#30 0xb74b8ac5 in KApplication::notify () from /opt/kde/lib/libkdecore.so.4
#31 0xb6e609cc in QEventLoop::activateTimers ()
   from /usr/lib/qt/lib/libqt-mt.so.3
#32 0xb6e194d1 in QEventLoop::processEvents ()
   from /usr/lib/qt/lib/libqt-mt.so.3
#33 0xb6e83b91 in QEventLoop::enterLoop () from /usr/lib/qt/lib/libqt-mt.so.3
#34 0xb6e83ae6 in QEventLoop::exec () from /usr/lib/qt/lib/libqt-mt.so.3
#35 0xb6e6c5cf in QApplication::exec () from /usr/lib/qt/lib/libqt-mt.so.3
#36 0x08063e32 in ?? ()
#37 0xb66f5e14 in __libc_start_main () from /lib/tls/libc.so.6
#38 0x08063911 in ?? ()
-----------------------------------------------------------------------------

---CTWaley
Comment 4 Joris Guisson 2007-01-23 18:55:29 UTC
We already fixed this after the 2.1rc1 release.