This forum has been archived. All content is frozen. Please use KDE Discuss instead.

2.2dev randomly crashes in Ubuntu; my solution

Tags: None
(comma "," separated)
tolos
Registered Member
Posts
4
Karma
0
Ok, I'd like to point out that I already know there are several things wrong with this.
1) I see that there's a newer version of ktorrent, which I just upgraded to. I have yet to see if it crashes frequently or not. By "frequently" I mean that when I run ktorrent it will usually only stay up and running for no more than 24 hours before hanging, then I have to open gnome-system-monitor and end any process I own with "kde" in it before ktorrent can restart.
2) This is my first attempt at any kind of in depth shell script, and this isn't even that in depth. I tried to do things "the right way" but since I lack experience in this field, someone else will have to point out my errors.

Ok, so what is my solution anyway? I created a bash script that will attempt to end all processes ktorrent spawns. Then it's simple to restart it. Ok, so this may not be the solution anyone reading this was hoping for.......

Code: Select all
#!/bin/bash

# this bash script attempts to nicely kill ALL the processes ktorrent spawns
# (after it crashes)
#
# what does it do?
#  -- finds known ktorrent processes, does a kill -15, waits 15 seconds
#       then a kill -2, 15 more seconds, and finally a kill -1
#       each time removing dead processes. If kill -15 ended everything,
#   then kill -1 shouldn't be run...
#
# what doesn't it do?
#  --  kill -9
#
# improvements / bugs?
# -- could store the lines of code that find out the PIDs of running processes in a function
#     instead of having the block of code/copy pasted
#
# sources
# -- http://wooledge.org/mywiki/BashFAQ
# -- http://wooledge.org/mywiki/ProcessManagement
# -- http://www.museum.state.il.us/ismdepts/library/linuxguides/abs-guide/arrays.html
#
# TolosTheMagician_gmail
# July 16, 2007

unset k            # if k was used before, make sure it's nothing now
unset count         # used for a loop later

declare -a k         # this is going to be an array

count=0
process_found=0         # no processes found so far...
sig_to_send=(15 2 1)      # signals to send (avoid SIGKILL ! (-9))
kill_these=(ktorrent kded klauncher dcopserver kio_file kio_uiserver kdeinit kio_http kbuildsycoca knotify)

# the following lines of code will go through the known processes ktorrent
# spawns, and if found, add to the list of processes that will be killed
# later. If no processes are found, then we'll just exit.

element_count=${#kill_these[@]}
index=0
while [ "$index" -lt "$element_count" ]
do
   if [[ $(pidof ${kill_these[$index]}) ]]
   then
      k[$count]=$(pidof ${kill_these[$index]})
      process_found=1
      let "count = $count + 1"
   fi
   let "index = $index + 1"
done

# ok, see if any processes were found.
# next, show which ones will be ended

element_count=${#k[@]}
index=0

if [ "$process_found" -eq 1 ]
then
   echo "The following processes will be ended: "
   while [ "$index" -lt "$element_count" ]
   do
      echo ${k[$index]}
      let "index = $index + 1"
   done
else
   echo "no processes found"
   exit 0
   return 0
fi


echo "Killing processes now..."

element_count=${#k[@]}
index=0
echo "doing kill -15 ..."
while [ "$index" -lt "$element_count" ]
do
   kill -15 ${k[$index]}
   killed=$?
   if [ $killed == 0 ]
   then
      echo "Successfully killed ${k[$index]}"
      unset k[$index]
   fi

   let "index = $index + 1"
done

echo "Waiting 15 seconds... "
sleep 15

process_found=0

element_count=${#kill_these[@]}
index=0
while [ "$index" -lt "$element_count" ]
do
   if [[ $(pidof ${kill_these[$index]}) ]]
   then
      k[$count]=$(pidof ${kill_these[$index]})
      process_found=1
      let "count = $count + 1"
   fi
   let "index = $index + 1"
done

if [ "$process_found" -eq 1 ]
then

element_count=${#k[@]}
index=0
echo "doing kill -2 on remaining processes ..."
while [ "$index" -lt "$element_count" ]
do
   kill -2 ${k[$index]}
   killed=$?
   if [ $killed == 0 ]
   then
      echo "Successfully killed ${k[$index]}"
      unset k[$index]
   fi

   let "index = $index + 1"
done

fi

echo "Waiting 15 more seconds...."
sleep 15


process_found=0

element_count=${#kill_these[@]}
index=0
while [ "$index" -lt "$element_count" ]
do
   if [[ $(pidof ${kill_these[$index]}) ]]
   then
      k[$count]=$(pidof ${kill_these[$index]})
      process_found=1
      let "count = $count + 1"
   fi
   let "index = $index + 1"
done

if [ "$process_found" -eq 1 ]
then


element_count=${#k[@]}
index=0
echo "doing kill -1 on remaining processes ..."
while [ "$index" -lt "$element_count" ]
do
   kill -1 ${k[$index]}
   killed=$?
   if [ $killed == 0 ]
   then
      echo "Successfully killed ${k[$index]}"
      unset k[$index]
   fi

   let "index = $index + 1"
done

fi


echo "Well, all process have tried to have been ended nicely. If they're still around .... "



If you run this, don't forget to chmod 755 :)
George
Moderator
Posts
5421
Karma
1

Tue Jul 17, 2007 7:36 pm
Do you have a backtrace of those crashes ?
tolos
Registered Member
Posts
4
Karma
0

Wed Jul 18, 2007 7:53 pm
Two things:

1) I don't know how to back trace.

2) Ktorrent doesn't crash, it just stops responding, so I have to kill everything in order to restart it.

And that means that after upgrading, I'm still having this problem.
George
Moderator
Posts
5421
Karma
1

Fri Jul 20, 2007 7:00 pm
Probably a deadlock.

Do you know how to use gdb ?
tolos
Registered Member
Posts
4
Karma
0

Sun Jul 22, 2007 5:33 am
George
Moderator
Posts
5421
Karma
1

Sun Jul 22, 2007 6:59 pm
Just do like this :

gdb /path/to/ktorrent
run --nofork

Wait until it hangs, then hit CTRL +C and :

bt

That should give some idea where it is stuck.

It would also be a good idea to recompile with debug enabled (./configure --enable-debug=full)
BigJim
Registered Member
Posts
46
Karma
0

Tue Jul 24, 2007 7:06 am
I am running a self-compiled svn-version (from last week) on Ubuntu edgy on i386. I never had any problems with stability.

tolos, do you have any specific things you're doing, or are you on a specific platform? Maybe I can help trying to reproduce the bug.
kinetik
Registered Member
Posts
4
Karma
0

Thu Jul 26, 2007 3:10 am
I just wanted to add my 2 cents on this matter i'm also having the same "bug/hang/freeze" thingy as tolos it tend to happen when I have alot of connection at the same time (300+) then hit the stop button and start to fast.

a quick review of my settings

ktorrent 2.2-0ubuntu(gutsy)
unlimited connection
50k upload max, 8 slot
unlimited download
dht enabled
protocol encryption, allow unencrypted


plugins enabled
IPBlocking filter with this list http://www.bluetack.co.uk/config/psplist.zip
Scanfolder (scan 1 folder, open silently, move to "loaded")
info widget (everything checked)
logview (everything set to all)


what I usualy do is tag a few tv show that I watch and they all load automaticly IF i grab em to fast my ktorrent will most likely hang and I gotta kill it and restart :(

Im not sure if that helps at all i'm not a coder if anyone want more specifics just ask i'll keep watching this tread.

-k

(I'm gonna give that backtrace a try if I can figure it out heh)
tolos
Registered Member
Posts
4
Karma
0

Tue Jul 31, 2007 4:58 am
Ok, I'll give a little bit more detailed information about my setup. Honestly I didn't think the dev would look into this, so thanks George!

I just installed ktorrent with apt-get. I'm not building from source. (Personal preference on ease of maintaining packages.)

version (2.2-0ubuntu)

uname -a
Linux tolos-desktop 2.6.20-15-generic #2 SMP Sun Apr 15 07:36:31 UTC 2007 i686 GNU/Linux

I've got a P4 2.0 ghz with no over clocking
630 mb of ram. That's two 256 pc800s and two more 64s.

My temp folder is on a mostly empty 60gb drive (/home).
My download folder is a 160gb drive with about 40gb free, so I don't think this is a space issue.

here's lspci output for my ethernet card:
Code: Select all
02:0b.0 Ethernet controller: VIA Technologies, Inc. VT86C100A [Rhine] (rev 06)
   Subsystem: D-Link System Inc DFE-530TX rev A
   Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV+ VGASnoop- ParErr- Stepping+ SERR- FastB2B-
   Status: Cap- 66MHz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
   Latency: 32 (29500ns min, 38000ns max), Cache Line Size: 32 bytes
   Interrupt: pin A routed to IRQ 185
   Region 0: I/O ports at d800 [size=128]
   Region 1: Memory at ed800000 (32-bit, non-prefetchable) [size=128]
   [virtual] Expansion ROM at efe00000 [disabled] [size=64K]


Ubuntu Feisty 7.04
Enlightentment 0.16.999.038

ktorrent config
Code: Select all
[downloads]
completedDir=/home/tolos
dhtPort=49224
dhtSupport=true
externalIP=[removed]
guiUpdateInterval=2
httpTrackerProxy=
lastSaveDir=/mnt/sea160/download/
maxConnections=14
maxDownloads=3
maxTotalConnections=28
maxUploadRate=6
numUploadSlots=3
port=49222
saveDir=/mnt/sea160/download/
showPopups=false
tempDir=/home/tolos/.kde/share/apps/ktorrent/
torrentCopyDir=/home/tolos
udpTrackerPort=49223
uploadBandwidth=25
useEncryption=true
useSaveDir=true


As to the nature of the crashes: it's not really a crash per se, more of ktorrent stops responding, and the only way to restart it is to kill all the processes it spawned.

And it's not like I can connect ktorrent hanging to anything. I mean, it's not like in the case of kinetik of hitting start and stop too frequently. I'll leave my computer alone for awhile, and come back, and ktorrent has froze. Or sometimes it will be when I'm using my computer. But it's not something I can reproduce. I just wait an hour or a day and eventually ktorrent has stopped responding.

I started ktorrent via gdb so I'll post a backtrace the next time it hangs.


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]