# microdc2 uses 100% CPU time

## tnt

microdc2 0.15.6 on gentoo amd64 

```
emerge -pv microdc2

These are the packages that would be merged, in order:

Calculating dependencies... done!

[ebuild   R   ] net-p2p/microdc2-0.15.6  USE="nls" 624 kB

Total size of downloads: 624 kB
```

after starting it runs for a while and then spawn a lot of processes and uses 100% CPU time (system time mostly):

```
titan    12236  0.0  0.1  20844  1132 pts/0    S    19:22   0:00 su - titan

titan    12237  0.0  0.1  10576  1872 pts/0    S    19:22   0:00 -su

titan    12884 54.0  1.1  23816 12304 pts/0    S+   19:24  14:50 microdc2

titan    12885  0.3  0.6  18052  6684 pts/0    SN+  19:24   0:05 microdc2

titan    12886  0.0  0.0  11620   496 pts/0    S+   19:24   0:00 microdc2

titan    12887  0.0  0.0  11620   496 pts/0    S+   19:24   0:00 microdc2

titan    12888  0.0  0.0  11620   500 pts/0    SN+  19:24   0:00 microdc2

titan    12895  0.0  0.6  17500  6192 pts/0    S+   19:24   0:00 microdc2

root     14383  0.0  0.2  30996  2660 ?        Ss   19:27   0:00 sshd: root@pts/1

root     14387  0.0  0.1  10312  1876 pts/1    Ss   19:27   0:00 -bash

titan    15512  0.0  0.6  17500  6256 pts/0    S+   19:30   0:00 microdc2

1002     20028  0.0  0.3  25436  3692 ?        S    19:41   0:00 /usr/sbin/smbd -D

root     22133  0.0  0.2  30996  2648 ?        Ss   19:47   0:00 sshd: root@pts/2

root     22137  0.0  0.1  10312  1884 pts/2    Ss+  19:47   0:00 -bash

titan    22406  0.0  1.1  23816 11424 pts/0    S+   19:48   0:00 microdc2

titan    22703  0.0  1.1  23816 11400 pts/0    S+   19:49   0:00 microdc2

titan    22704  0.0  1.1  23816 11400 pts/0    S+   19:49   0:00 microdc2

titan    22705  0.0  1.1  23816 11400 pts/0    S+   19:49   0:00 microdc2

titan    22742  0.0  1.1  23816 11400 pts/0    S+   19:49   0:00 microdc2

titan    22755  0.0  1.1  23816 11400 pts/0    S+   19:49   0:00 microdc2

titan    23289  0.0  1.1  23816 11400 pts/0    S+   19:50   0:00 microdc2

titan    23534  0.0  1.1  23816 11400 pts/0    S+   19:50   0:00 microdc2

titan    23535  0.0  1.1  23816 11400 pts/0    S+   19:50   0:00 microdc2

titan    23608  0.0  1.1  23816 11400 pts/0    S+   19:50   0:00 microdc2

titan    23745  0.0  1.1  23816 11400 pts/0    S+   19:50   0:00 microdc2

titan    23746  0.0  1.1  23816 11400 pts/0    S+   19:50   0:00 microdc2

titan    23922  0.0  1.1  23816 11400 pts/0    S+   19:51   0:00 microdc2

titan    23923  0.0  1.1  23816 11400 pts/0    S+   19:51   0:00 microdc2

titan    23959  0.0  1.1  23816 11400 pts/0    S+   19:51   0:00 microdc2

root     23994  0.0  0.0   4864   576 ?        S    19:51   0:00 sleep 10

titan    23998  0.5  1.1  23816 11400 pts/0    S+   19:51   0:00 microdc2

titan    23999  0.0  1.1  23816 11400 pts/0    S+   19:51   0:00 microdc2

root     24000  0.0  0.0   8488   992 pts/1    R+   19:51   0:00 ps aux

```

http://titan.blok44.net/temp/cpu.png

microdc2 seems to work - there are new connections and clients can download from it:

```
User unknown16: Connected to user.

User unknown17: Idle timeout (180 seconds)

Shutting down user connection process for `unknown17'.

User unknown11: Idle timeout (180 seconds)

Shutting down user connection process for `unknown11'.

User unknown7: Idle timeout (180 seconds)

Shutting down user connection process for `unknown7'.

User Goran quits.

Connecting to user on 10.0.10.88:5444

Connecting to user on 192.168.4.27:11346

User unknown10: Connected to user.

User unknown12: Connected to user.

User connection `unknown5' renamed to `razarac|'.

User doctore|: Idle timeout (180 seconds)

Shutting down user connection process for `doctore|'.

User omsuk quits.

User unknown13: Idle timeout (180 seconds)

Shutting down user connection process for `unknown13'.

Connecting to user on 192.168.8.46:4476

User unknown4: Connected to user.

Connecting to user on 10.0.10.36:5444

User unknown8: Connected to user.

User unknown15: Idle timeout (180 seconds)

Shutting down user connection process for `unknown15'.

Connecting to user on 10.0.10.85:5444

User unknown17: Connected to user.

microdc2> set

active                     on

auto_reconnect             on

description                titan@microdc2

display                    connections download joinpart publicchat searchresults upload

downloaddir                /home/titan

email

filelist_refresh_interval  3600

filesystem_charset         iso-8859-1

hub_charset                iso-8859-1

listenaddr                 10.0.9.1

listenport                 5444

listingdir                 /tmp/microdc2.12884

log                        connections download joinpart publicchat searchresults upload

log_charset                (unset)

logfile                    (unset)

nick                       titan.b44

password                   (unset)

slots                      5

speed                      cable

tag                        microdc2 V:0.15.6

microdc2>
```

but CPU utilisation is very very high:

```
top - 19:59:50 up 86 days, 17:53,  3 users,  load average: 1.50, 1.84, 1.61

Tasks: 137 total,   2 running, 135 sleeping,   0 stopped,   0 zombie

Cpu(s): 14.3% us, 84.7% sy,  0.0% ni,  0.0% id,  0.0% wa,  0.0% hi,  1.0% si

Mem:   1027528k total,  1018192k used,     9336k free,    39256k buffers

Swap:  1959768k total,   573196k used,  1386572k free,   160048k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND

12884 titan     25   0 23816  12m 1336 S 99.7  1.2  22:28.56 microdc2

13058 named     25   0 49848 7440 1692 S  0.3  0.7  11:59.83 named

    1 root      16   0  2704  484  448 S  0.0  0.0   0:00.71 init

    2 root      34  19     0    0    0 S  0.0  0.0   0:01.97 ksoftirqd/0

    3 root      10  -5     0    0    0 S  0.0  0.0   0:00.76 events/0

    4 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 khelper

    5 root      10  -5     0    0    0 S  0.0  0.0   0:00.01 kthread

    7 root      10  -5     0    0    0 S  0.0  0.0   3:05.77 kblockd/0

    8 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 kacpid

  140 root      16  -5     0    0    0 S  0.0  0.0   0:00.00 kseriod

```

when I exit microdc2 I get:

```
microdc2> exit

Shutting down hub connection.

Shutting down user connection process for `unknown9'.

Shutting down user connection process for `unknown20'.

Shutting down user connection process for `unknown21'.

Shutting down user connection process for `unknown22'.

*** glibc detected *** microdc2: realloc(): invalid pointer: 0x0000000000924da0 ***

*** glibc detected *** microdc2: corrupted double-linked list: 0x0000000000924da0 ***

Inconsistency detected by ld.so: dl-open.c: 215: dl_open_worker: Assertion `_dl_debug_initialize (0, args->nsid)->r_state == RT_CONSISTENT' failed!

```

maybe that could leed to some solution...

```
emerge --info

Portage 2.1.1-r2 (default-linux/amd64/2006.1, gcc-4.1.1, glibc-2.4-r4, 2.6.17-gentoo-r8 x86_64)

=================================================================

System uname: 2.6.17-gentoo-r8 x86_64 AMD Athlon(tm) 64 Processor 3000+

Gentoo Base System version 1.12.6

Last Sync: Thu, 18 Jan 2007 15:00:01 +0000

distcc 2.18.3 x86_64-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled]

app-admin/eselect-compiler: [Not Present]

dev-java/java-config: 1.3.7, 2.0.30

dev-lang/python:     2.3.5-r2, 2.4.3-r4

dev-python/pycrypto: 2.0.1-r5

dev-util/ccache:     [Not Present]

dev-util/confcache:  [Not Present]

sys-apps/sandbox:    1.2.17

sys-devel/autoconf:  2.13, 2.61

sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10

sys-devel/binutils:  2.16.1-r3

sys-devel/gcc-config: 1.3.14

sys-devel/libtool:   1.5.22

virtual/os-headers:  2.6.11-r2

ACCEPT_KEYWORDS="amd64"

AUTOCLEAN="yes"

CBUILD="x86_64-pc-linux-gnu"

CFLAGS="-march=athlon64 -O2 -pipe -fomit-frame-pointer"

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc /opt/wildfire/resources/security/ /var/bind"

CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/gconf /etc/java-config/vms/ /etc/revdep-rebuild /etc/terminfo"

CXXFLAGS="-march=athlon64 -O2 -pipe -fomit-frame-pointer"

DISTDIR="/users/tnt/ftp/gentoo/distfiles"

FEATURES="autoconfig distlocks metadata-transfer parallel-fetch sandbox sfperms strict"

GENTOO_MIRRORS="http://ftp-stud.fht-esslingen.de/pub/Mirrors/gentoo/ http://gd.tuwien.ac.at/opsys/linux/gentoo/ ftp://mirror.etf.bg.ac.yu/gentoo/"

MAKEOPTS="-j2"

PKGDIR="/usr/portage/packages"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude='/distfiles' --exclude='/local' --exclude='/packages'"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY="/usr/local/portage"

SYNC="rsync://rsync.gentoo.org/gentoo-portage"

USE="amd64 64bit a52 aac aalib acpi alsa_cards_ali5451 alsa_cards_als4000 alsa_cards_atiixp alsa_cards_atiixp-modem alsa_cards_bt87x alsa_cards_ca0106 alsa_cards_cmipci alsa_cards_emu10k1x alsa_cards_ens1370 alsa_cards_ens1371 alsa_cards_es1938 alsa_cards_es1968 alsa_cards_fm801 alsa_cards_hda-intel alsa_cards_intel8x0 alsa_cards_intel8x0m alsa_cards_maestro3 alsa_cards_trident alsa_cards_usb-audio alsa_cards_via82xx alsa_cards_via82xx-modem alsa_cards_ymfpci alsa_pcm_plugins_adpcm alsa_pcm_plugins_alaw alsa_pcm_plugins_asym alsa_pcm_plugins_copy alsa_pcm_plugins_dmix alsa_pcm_plugins_dshare alsa_pcm_plugins_dsnoop alsa_pcm_plugins_empty alsa_pcm_plugins_extplug alsa_pcm_plugins_file alsa_pcm_plugins_hooks alsa_pcm_plugins_iec958 alsa_pcm_plugins_ioplug alsa_pcm_plugins_ladspa alsa_pcm_plugins_lfloat alsa_pcm_plugins_linear alsa_pcm_plugins_meter alsa_pcm_plugins_mulaw alsa_pcm_plugins_multi alsa_pcm_plugins_null alsa_pcm_plugins_plug alsa_pcm_plugins_rate alsa_pcm_plugins_route alsa_pcm_plugins_share alsa_pcm_plugins_shm alsa_pcm_plugins_softvol amr apache2 berkdb bitmap-fonts bzip2 cli cracklib crypt cups dlloader dri dts dvb elibc_glibc encode exif extensions ffmpeg freetype gd gdbm geoip gif gpm httpd iconv imagemagick imap imlib input_devices_evdev input_devices_keyboard input_devices_mouse iproute2 isdnlog ithreads jabber jbig jpeg kernel_linux lcd_devices_bayrad lcd_devices_cfontz lcd_devices_cfontz633 lcd_devices_glk lcd_devices_hd44780 lcd_devices_lb216 lcd_devices_lcdm001 lcd_devices_mtxorb lcd_devices_ncurses lcd_devices_text libg++ libwww lm_sensors logrotate lzo maildir mod mp3 mpeg multipath mysql ncurses nls nptl nptlonly ogg oggvorbis pam pam-mysql pcre perl php png pppd python readline reflection rle rrdtool samba sasl session slang snmp spl ssl stream tcpd theora threads tiff transcode truetype truetype-fonts type1-fonts udev unicode usb userland_GNU vcd video_cards_apm video_cards_ark video_cards_ati video_cards_chips video_cards_cirrus video_cards_cyrix video_cards_dummy video_cards_fbdev video_cards_glint video_cards_i128 video_cards_i810 video_cards_mga video_cards_neomagic video_cards_nv video_cards_rendition video_cards_s3 video_cards_s3virge video_cards_savage video_cards_siliconmotion video_cards_sis video_cards_sisusb video_cards_tdfx video_cards_tga video_cards_trident video_cards_tseng video_cards_v4l video_cards_vesa video_cards_vga video_cards_via video_cards_vmware video_cards_voodoo vorbis wmf xml xorg xvid zlib"

Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, LINGUAS, PORTAGE_RSYNC_EXTRA_OPTS
```

any idea?

 :Question: 

----------

## latrell

Does it relate to the while loop in the main function? Microdc2 seems to stay in the while loop which could make cpu usage high.

Latrell.

----------

## tnt

don't know about that. more details on this problem here:

https://bugs.gentoo.org/show_bug.cgi?id=162828

----------

