[devel] QA: socket programming - mem leaks
Peter V. Saveliev
=?iso-8859-1?q?peet_=CE=C1_altlinux=2Eru?=
Пн Фев 2 20:43:58 MSK 2004
...
Столкнулся с неприятной штукой, при прогоне своей программы через valgrind:
8<------------------------------------------------------------------
==19598== Conditional jump or move depends on uninitialised value(s)
==19598== at 0x11CBD6: (within /lib/ld-2.2.6.so)
8<------------------------------------------------------------------
Это вначале выполнения. Причиной является использование gethostbyname,
как показалось. Дальше - больше:
8<------------------------------------------------------------------
==19608== malloc/free: in use at exit: 672 bytes in 6 blocks.
==19608== malloc/free: 64 allocs, 58 frees, 54736 bytes allocated.
==19608==
==19608== searching for pointers to 6 not-freed blocks.
==19608== checked 3498272 bytes.
==19608==
==19608==
==19608== 16 bytes in 1 blocks are definitely lost in loss record 1 of 6
==19608== at 0x134BAA: malloc (vg_replace_malloc.c:153)
==19608== by 0x804A1A2: main (main.c:400)
==19608== by 0x366681: __libc_start_main (in /lib/libc-2.2.6.so)
==19608== by 0x8048AA0: (within /home/peet/Projects/icaph/icaph)
==19608==
==19608==
==19608== 23 bytes in 1 blocks are still reachable in loss record 2 of 6
==19608== at 0x134BAA: malloc (vg_replace_malloc.c:153)
==19608== by 0x117F91: (within /lib/ld-2.2.6.so)
==19608== by 0x11407D: (within /lib/ld-2.2.6.so)
==19608== by 0x11532B: _dl_map_object (in /lib/ld-2.2.6.so)
==19608==
==19608==
==19608== 23 bytes in 1 blocks are still reachable in loss record 3 of 6
==19608== at 0x134BAA: malloc (vg_replace_malloc.c:153)
==19608== by 0x1156E4: _dl_map_object (in /lib/ld-2.2.6.so)
==19608== by 0x444220: (within /lib/libc-2.2.6.so)
==19608== by 0x119A45: _dl_catch_error (in /lib/ld-2.2.6.so)
==19608==
==19608==
==19608== 28 bytes in 1 blocks are still reachable in loss record 4 of 6
==19608== at 0x134BAA: malloc (vg_replace_malloc.c:153)
==19608== by 0x118CD6: _dl_map_object_deps (in /lib/ld-2.2.6.so)
==19608== by 0x4442B4: (within /lib/libc-2.2.6.so)
==19608== by 0x119A45: _dl_catch_error (in /lib/ld-2.2.6.so)
==19608==
==19608==
==19608== 128 bytes in 1 blocks are still reachable in loss record 5 of 6
==19608== at 0x13503A: calloc (vg_replace_malloc.c:284)
==19608== by 0x11AC13: _dl_check_map_versions (in /lib/ld-2.2.6.so)
==19608== by 0x44463E: (within /lib/libc-2.2.6.so)
==19608== by 0x119A45: _dl_catch_error (in /lib/ld-2.2.6.so)
==19608==
==19608==
==19608== 454 bytes in 1 blocks are still reachable in loss record 6 of 6
==19608== at 0x13503A: calloc (vg_replace_malloc.c:284)
==19608== by 0x117D62: (within /lib/ld-2.2.6.so)
==19608== by 0x11407D: (within /lib/ld-2.2.6.so)
==19608== by 0x11532B: _dl_map_object (in /lib/ld-2.2.6.so)
==19608==
==19608== LEAK SUMMARY:
==19608== definitely lost: 16 bytes in 1 blocks.
==19608== possibly lost: 0 bytes in 0 blocks.
==19608== still reachable: 656 bytes in 5 blocks.
==19608== suppressed: 0 bytes in 0 blocks.
8<------------------------------------------------------------------
Как выяснилось в результате некоторого усилия, сходная картина
наблюдается при использовании netcat и telnet.
Это избывается только полным изъятием из кода любой клиентской части,
начиная с connect. В программе, которая в коде несёт только сервер,
такого поведения не демонстрирует.
версия glibc -
[peet на kelisaari peet]$ rpm -qa | grep glibc
glibc-2.2.6-alt0.11
glibc-gconv-modules-2.2.6-alt0.11
glibc-devel-static-2.2.6-alt0.11
glibc-utils-2.2.6-alt0.11
glibc-kernheaders-2.4.21-alt1
glibc-nss-2.2.6-alt0.11
glibc-timezones-2.2.6-alt0.11
glibc-core-2.2.6-alt0.11
glibc-locales-2.2.6-alt0.11
glibc-devel-2.2.6-alt0.11
drweb-4.30-glibc.2.2
На других версиях/дистрибутивах пока не гонял.
Это какая-то известная фича, с которой я просто впервые сталкиваюсь в
результате малого опыта, или таракан в голове, или просто бага такая?
--
<signature />
Подробная информация о списке рассылки Devel