Using Valgrind to detect Memory Leaks (still reachable)

ABOUT Memory Leak

In computer science, a memory leak is a type of resource leak that occurs when a computer program incorrectly manages memory allocations[1] in such a way that memory which is no longer needed is not released. A memory leak may also happen when an object is stored in memory but cannot be accessed by the running code.[2] A memory leak has symptoms similar to a number of other problems and generally can only be diagnosed by a programmer with access to the program's source code.

A space leak occurs when a computer program uses more memory than necessary. In contrast to memory leaks, where the leaked memory is never released, the memory consumed by a space leak is released, but later than expected. [3]

Because they can exhaust available system memory as an application runs, memory leaks are often the cause of or a contributing factor to software aging.

ABOUT Valgrind

Valgrind /ˈvælɡrɪnd/ is a programming tool for memory debugging, memory leak detection, and profiling.

Valgrind was originally designed to be a free memory debugging tool for Linux on x86, but has since evolved to become a generic framework for creating dynamic analysis tools such as checkers and profilers.

The name Valgrind is a reference to the main entrance of Valhalla from Norse Mythology. During development (before release) the project was named Heimdall; however, the name would have conflicted with a security package.

TYPICAL COMMANDLINE SESSION
[text light=”true”]
$valgrind -v –tool=memcheck –leak-check=full ./ethstatus -i eth1
==19477== Memcheck, a memory error detector
==19477== Copyright (C) 2002-2012, and GNU GPL’d, by Julian Seward et al.
==19477== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==19477== Command: ./ethstatus -i eth1
==19477==
–19477– Valgrind options:
–19477– –suppressions=/usr/lib/valgrind/debian-libc6-dbg.supp
–19477– -v
–19477– –tool=memcheck
–19477– –leak-check=full
–19477– Contents of /proc/version:
–19477– Linux version 3.11.0 (root@debian) (gcc version 4.7.3 (Debian 4.7.3-4) ) #1 SMP Mon Sep 16 00:32:04 IST 2013
–19477– Arch and hwcaps: AMD64, amd64-sse3-cx16-lzcnt-avx
–19477– Page sizes: currently 4096, max supported 4096
–19477– Valgrind library directory: /usr/lib/valgrind
–19477– Reading syms from /home/jeffrin/Cloud/debian-develop/ethstatus-0.4.3/ethstatus
–19477– Reading syms from /lib/x86_64-linux-gnu/ld-2.17.so
–19477– Considering /lib/x86_64-linux-gnu/ld-2.17.so ..
–19477– .. CRC mismatch (computed bf253f8a wanted e079394a)
–19477– Considering /usr/lib/debug/lib/x86_64-linux-gnu/ld-2.17.so ..
–19477– .. CRC is valid
–19477– Reading syms from /usr/lib/valgrind/memcheck-amd64-linux
–19477– Considering /usr/lib/valgrind/memcheck-amd64-linux ..
–19477– .. CRC mismatch (computed 3468463e wanted c047c437)
–19477– Considering /usr/lib/debug/usr/lib/valgrind/memcheck-amd64-linux ..
–19477– .. CRC is valid
–19477– object doesn’t have a dynamic symbol table
–19477– Scheduler: using generic scheduler lock implementation.
–19477– Reading suppressions file: /usr/lib/valgrind/debian-libc6-dbg.supp
–19477– Reading suppressions file: /usr/lib/valgrind/default.supp
==19477== embedded gdbserver: reading from /tmp/vgdb-pipe-from-vgdb-to-19477-by-jeffrin-on-???
==19477== embedded gdbserver: writing to /tmp/vgdb-pipe-to-vgdb-from-19477-by-jeffrin-on-???
==19477== embedded gdbserver: shared mem /tmp/vgdb-pipe-shared-mem-vgdb-19477-by-jeffrin-on-???
==19477==
==19477== TO CONTROL THIS PROCESS USING vgdb (which you probably
==19477== don’t want to do, unless you know exactly what you’re doing,
==19477== or are doing some strange experiment):
==19477== /usr/lib/valgrind/../../bin/vgdb –pid=19477 …command…
==19477==
==19477== TO DEBUG THIS PROCESS USING GDB: start GDB like this
==19477== /path/to/gdb ./ethstatus
==19477== and then give GDB the following command
==19477== target remote | /usr/lib/valgrind/../../bin/vgdb –pid=19477
==19477== –pid is optional if only one valgrind process is running
==19477==
–19477– REDIR: 0x4017890 (strlen) redirected to 0x3806c661 (vgPlain_amd64_linux_REDIR_FOR_strlen)
–19477– Reading syms from /usr/lib/valgrind/vgpreload_core-amd64-linux.so
–19477– Considering /usr/lib/valgrind/vgpreload_core-amd64-linux.so ..
–19477– .. CRC mismatch (computed 3468909c wanted 2ffaf283)
–19477– Considering /usr/lib/debug/usr/lib/valgrind/vgpreload_core-amd64-linux.so ..
–19477– .. CRC is valid
–19477– Reading syms from /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so
–19477– Considering /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so ..
–19477– .. CRC mismatch (computed c6ae4a33 wanted 21397e4b)
–19477– Considering /usr/lib/debug/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so ..
–19477– .. CRC is valid
–19477– REDIR: 0x4017700 (index) redirected to 0x4c2c4b0 (index)
–19477– REDIR: 0x4017780 (strcmp) redirected to 0x4c2d4c0 (strcmp)
–19477– Reading syms from /usr/lib/debug/libncurses.so.5.9
–19477– Reading syms from /usr/lib/debug/libtinfo.so.5.9
–19477– Reading syms from /lib/x86_64-linux-gnu/libc-2.17.so
–19477– Considering /lib/x86_64-linux-gnu/libc-2.17.so ..
–19477– .. CRC mismatch (computed b0b3185d wanted a268c1003)
–19477– Considering /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.17.so ..
–19477– .. CRC is valid
–19477– Reading syms from /lib/x86_64-linux-gnu/libdl-2.17.so
–19477– Considering /lib/x86_64-linux-gnu/libdl-2.17.so ..
–19477– .. CRC mismatch (computed 2a2457cb wanted a5918d1a)
–19477– Considering /usr/lib/debug/lib/x86_64-linux-gnu/libdl-2.17.so ..
–19477– .. CRC is valid
–19477– REDIR: 0x5317e40 (strcasecmp) redirected to 0x4a24710 (_vgnU_ifunc_wrapper)
–19477– REDIR: 0x5314200 (strnlen) redirected to 0x4a24710 (_vgnU_ifunc_wrapper)
–19477– REDIR: 0x531a110 (strncasecmp) redirected to 0x4a24710 (_vgnU_ifunc_wrapper)
–19477– REDIR: 0x5316c50 (memset) redirected to 0x4a24710 (_vgnU_ifunc_wrapper)
–19477– REDIR: 0x5316c00 (memcpy@GLIBC_2.2.5) redirected to 0x4a24710 (_vgnU_ifunc_wrapper)
–19477– REDIR: 0x5315bf0 (__GI_strrchr) redirected to 0x4c2c2d0 (__GI_strrchr)
–19477– REDIR: 0xffffffffff600400 (???) redirected to 0x3806c64d (vgPlain_amd64_linux_REDIR_FOR_vtime)
–19477– REDIR: 0x5314120 (__GI_strlen) redirected to 0x4c2c830 (__GI_strlen)
–19477– REDIR: 0x530e4f0 (free) redirected to 0x4c2aa70 (free)
–19477– REDIR: 0x530e0d0 (malloc) redirected to 0x4c2bd80 (malloc)
–19477– REDIR: 0x5313ab0 (__GI_strcpy) redirected to 0x4c2c920 (__GI_strcpy)
–19477– REDIR: 0x5312620 (__GI_strcmp) redirected to 0x4c2d470 (__GI_strcmp)
–19477– REDIR: 0x531dc10 (__GI___rawmemchr) redirected to 0x4c2ee90 (__GI___rawmemchr)
–19477– REDIR: 0x531de20 (strchrnul) redirected to 0x4c2ee40 (strchrnul)
–19477– REDIR: 0x5314230 (__GI_strnlen) redirected to 0x4c2c7e0 (__GI_strnlen)
–19477– REDIR: 0x5312560 (__GI_strchr) redirected to 0x4c2c3b0 (__GI_strchr)
Running EthStatus v0.4a…–19477– REDIR: 0x5314320 (__GI_strncmp) redirected to 0x4c2cd00 (__GI_strncmp)
–19477– REDIR: 0x53140d0 (strlen) redirected to 0x4a24710 (_vgnU_ifunc_wrapper)
–19477– REDIR: 0x530ea30 (calloc) redirected to 0x4c29ba0 (calloc)
–19477– REDIR: 0x5315bb0 (rindex) redirected to 0x4a24710 (_vgnU_ifunc_wrapper)
–19477– REDIR: 0x5312520 (index) redirected to 0x4a24710 (_vgnU_ifunc_wrapper)
–19477– REDIR: 0x5313a70 (strcpy) redirected to 0x4a24710 (_vgnU_ifunc_wrapper)
–19477– REDIR: 0x53125e0 (strcmp) redirected to 0x4a24710 (_vgnU_ifunc_wrapper)
–19477– REDIR: 0x531c7f0 (memcpy@@GLIBC_2.14) redirected to 0x4a24710 (_vgnU_ifunc_wrapper)
–19477– REDIR: 0x531c840 (__GI_memcpy) redirected to 0x4c2d7f0 (memcpy@@GLIBC_2.14)
–19477– REDIR: 0x530e580 (realloc) redirected to 0x4c2bf80 (realloc)
–19477– REDIR: 0x5315b70 (strncpy) redirected to 0x4a24710 (_vgnU_ifunc_wrapper)
–19477– REDIR: 0x53214b0 (__GI_strncpy) redirected to 0x4c2cb40 (__GI_strncpy)
–19477– REDIR: 0x532b4f0 (strstr) redirected to 0x4a24710 (_vgnU_ifunc_wrapper)
–19477– REDIR: 0x532b060 (__GI_strstr) redirected to 0x4c2f240 (strstr)

EthStatus v0.4a – Gabriel Montenegro / Christoph Haas

==19477==
==19477== HEAP SUMMARY:
==19477== in use at exit: 85,525 bytes in 122 blocks
==19477== total heap usage: 22,300 allocs, 22,178 frees, 6,549,861 bytes allocated
==19477==
==19477== Searching for pointers to 122 not-freed blocks
==19477== Checked 227,344 bytes
==19477==
==19477== LEAK SUMMARY:
==19477== definitely lost: 0 bytes in 0 blocks
==19477== indirectly lost: 0 bytes in 0 blocks
==19477== possibly lost: 0 bytes in 0 blocks
==19477== still reachable: 85,525 bytes in 122 blocks
==19477== suppressed: 0 bytes in 0 blocks
==19477== Reachable blocks (those to which a pointer was found) are not shown.
==19477== To see them, rerun with: –leak-check=full –show-reachable=yes
==19477==
==19477== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)
–19477–
–19477– used_suppression: 2 dl-hack3-cond-1
==19477==
==19477== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)
$

[/text]
LINKS
https://en.wikipedia.org/wiki/Valgrind
https://en.wikipedia.org/wiki/Memory_leak
https://stackoverflow.com/questions/26137356/how-to-check-actual-memory-leaks-during-runtime-using-valgrind
https://www.ibm.com/developerworks/library/l-memory-leaks/index.html
https://www.ibm.com/developerworks/systems/library/es-debug/index.html

Detecting Memory Leaks (leak: + ive)

commandline session

$gcc -g leak.c
$valgrind --tool=memcheck --leak-check=full ./a.out
==4353== Memcheck, a memory error detector
==4353== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==4353== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==4353== Command: ./a.out
==4353==
==4353==
==4353== HEAP SUMMARY:
==4353==     in use at exit: 100 bytes in 1 blocks
==4353==   total heap usage: 1 allocs, 0 frees, 100 bytes allocated
==4353==
==4353== 100 bytes in 1 blocks are definitely lost in loss record 1 of 1
==4353==    at 0x4C2BDEB: malloc (vg_replace_malloc.c:270)
==4353==    by 0x40050D: main (leak.c:4)
==4353==
==4353== LEAK SUMMARY:
==4353==    definitely lost: 100 bytes in 1 blocks
==4353==    indirectly lost: 0 bytes in 0 blocks
==4353==      possibly lost: 0 bytes in 0 blocks
==4353==    still reachable: 0 bytes in 0 blocks
==4353==         suppressed: 0 bytes in 0 blocks
==4353==
==4353== For counts of detected and suppressed errors, rerun with: -v
==4353== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 2 from 2)
$cat leak.c
#include 
int main()
{
  char *x = (char*) malloc(100); //Mem Leak!
  return 0;
}
$

Detecting Memory Leaks II

commandline session

$gcc -g -ansi -pedantic -W -Wall algorithm.c
algorithm.c: In function ‘main’:
algorithm.c:47:5: warning: unused variable ‘value’ [-Wunused-variable]
algorithm.c:36:7: warning: unused variable ‘p’ [-Wunused-variable]
algorithm.c:35:5: warning: unused variable ‘i’ [-Wunused-variable]
algorithm.c:34:14: warning: unused parameter ‘argc’ [-Wunused-parameter]
algorithm.c:34:26: warning: unused parameter ‘argv’ [-Wunused-parameter]
$valgrind --tool=memcheck --leak-check=full ./a.out
==23555== Memcheck, a memory error detector
==23555== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==23555== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==23555== Command: ./a.out
==23555==
found in: htop-0.9
found in: .
==23555==
==23555== HEAP SUMMARY:
==23555==     in use at exit: 0 bytes in 0 blocks
==23555==   total heap usage: 74 allocs, 74 frees, 45,235 bytes allocated
==23555==
==23555== All heap blocks were freed -- no leaks are possible
==23555==
==23555== For counts of detected and suppressed errors, rerun with: -v
==23555== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)
$

Detecting Memory leaks

commandline session

$valgrind --tool=memcheck --leak-check=full ./a.out
==6002== Memcheck, a memory error detector
==6002== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==6002== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==6002== Command: ./a.out
==6002==
-31
0
1
2
2
4
100
83
99
782
==6002==
==6002== HEAP SUMMARY:
==6002==     in use at exit: 0 bytes in 0 blocks
==6002==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==6002==
==6002== All heap blocks were freed -- no leaks are possible
==6002==
==6002== For counts of detected and suppressed errors, rerun with: -v
==6002== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)
$

Running Unit tests

commandline session

$./utils/unittest_suite.py
Number of test modules found: 59
autotest.client.kernel_versions_unittest: PASS
autotest.client.shared.profiler_manager_unittest: PASS
autotest.mirror.database_unittest: PASS
autotest.client.shared.autotemp_unittest: PASS
autotest.tko.utils_unittest: PASS
autotest.client.harness_unittest: PASS
autotest.client.shared.hosts.base_classes_unittest: PASS
autotest.client.setup_job_unittest: PASS
autotest.mirror.source_unittest: PASS
autotest.client.fsinfo_unittest: PASS
autotest.client.shared.base_job_unittest: PASS
autotest.server.hosts.remote_unittest: PASS
autotest.database_legacy.database_connection_unittest: FAIL
autotest.server.hosts.monitors.monitors_util_unittest: PASS
autotest.server.hosts.monitors.console_patterns_unittest: FAIL
autotest.client.net.net_tc_unittest: PASS
autotest.client.partition_unittest: PASS
autotest.cli.user_unittest: PASS
autotest.scheduler.drone_manager_unittest: PASS
autotest.client.local_host_unittest: PASS
autotest.cli.rpc_unittest: PASS
autotest.scheduler.drones_unittest: PASS
autotest.cli.job_unittest: PASS
autotest.client.net.net_utils_unittest: FAIL
autotest.server.hosts.bootloader_unittest: PASS
autotest.cli.test_unittest: PASS
autotest.cli.topic_common_unittest: PASS
autotest.client.shared.settings_unittest: FAIL
autotest.client.shared.boottool_unittest: PASS
autotest.server.hosts.monitors.console_unittest: PASS
autotest.scheduler.gc_stats_unittest: PASS
autotest.server.rpm_kernel_unittest: PASS
autotest.server.base_utils_unittest: PASS
autotest.tko.status_lib_unittest: PASS
autotest.client.shared.control_data_unittest: PASS
autotest.tko.parsers.version_0_unittest: PASS
autotest.cli.atest_unittest: PASS
autotest.server.hosts.base_classes_unittest: PASS
autotest.server.subcommand_unittest: PASS
autotest.server.autoserv_parser_unittest: PASS
autotest.client.shared.mail_unittest: PASS
autotest.client.shared.test_unittest: PASS
autotest.server.deb_kernel_unittest: PASS
autotest.client.fsdev_disks_unittest: PASS
autotest.tko.parsers.version_1_unittest: PASS
autotest.server.server_job_unittest: PASS
autotest.cli.acl_unittest: PASS
autotest.client.kernelexpand_unittest: PASS
autotest.cli.atomicgroup_unittest: PASS
autotest.server.autotest_remote_unittest: PASS
autotest.cli.action_common_unittest: PASS
autotest.server.source_kernel_unittest: PASS
autotest.cli.host_unittest: PASS
autotest.cli.label_unittest: PASS
autotest.client.job_unittest: PASS
autotest.scheduler.drone_utility_unittest: PASS
autotest.client.kernel_unittest: PASS
autotest.client.shared.base_utils_unittest: PASS
autotest.cli.threads_unittest: PASS
4 tests resulted in an error/failure:
	autotest.database_legacy.database_connection_unittest failed
	autotest.server.hosts.monitors.console_patterns_unittest failed
	autotest.client.net.net_utils_unittest failed
	autotest.client.shared.settings_unittest failed
Rerun ./utils/unittest_suite.py --debug to see the failure details.
$

Autotest Unittest suite. Setting up dependencies

Get The Hang

$sudo ./utils/build_externals.py
20:28:50 INFO | imported setuptools version 0.6.
20:28:50 INFO | A new Setuptools is not needed on this system.
20:28:50 INFO | MySQLdb isn't present. Will install.
20:28:50 INFO | Fetching http://downloads.sourceforge.net/project/mysql-python/mysql-python/1.2.2/MySQL-python-1.2.2.tar.gz
20:28:52 INFO | Good checksum.
20:28:52 INFO | imported django version 1.5.1.
20:28:52 INFO | A new Django is not needed on this system.
20:28:52 INFO | imported numpy version 1.6.2.
20:28:52 INFO | A new Numpy is not needed on this system.
20:28:52 INFO | imported matplotlib version 1.1.1rc2.
20:28:52 INFO | A new Matplotlib is not needed on this system.
20:28:52 INFO | atfork isn't present. Will install.
20:28:52 INFO | Fetching http://python-atfork.googlecode.com/files/atfork-0.1.2.zip
20:28:53 INFO | Good checksum.
20:28:53 INFO | imported paramiko version 1.7.7.1 (George).
20:28:53 INFO | A new Paramiko is not needed on this system.
20:28:53 INFO | imported simplejson version 2.6.2.
20:28:53 INFO | A new Simplejson is not needed on this system.
20:28:53 INFO | imported httplib2 version 0.6.0.
20:28:53 INFO | A new Httplib2 is not needed on this system.
20:28:53 INFO | gwt not installed for autotest
20:28:53 INFO | Fetching http://google-web-toolkit.googlecode.com/files/gwt-2.4.0.zip
20:35:03 INFO | Good checksum.
20:35:03 INFO | tar -xzf '/usr/local/lib/python2.7/dist-packages/autotest/ExternalSource/MySQL-python-1.2.2.tar.gz'
20:35:03 INFO | '/usr/bin/python' setup.py bdist_egg
running bdist_egg
running egg_info
writing MySQL_python.egg-info/PKG-INFO
writing top-level names to MySQL_python.egg-info/top_level.txt
writing dependency_links to MySQL_python.egg-info/dependency_links.txt
deleting MySQL_python.egg-info/native_libs.txt
reading manifest file 'MySQL_python.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'MySQL_python.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib.linux-x86_64-2.7
copying _mysql_exceptions.py -> build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-2.7/MySQLdb
creating build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.linux-x86_64-2.7
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,2,'final',0) -D__version__=1.2.2 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -DBIG_JOINS=1 -fno-strict-aliasing -g
In file included from _mysql.c:35:0:
/usr/include/mysql/my_config.h:422:0: warning: "HAVE_WCSCOLL" redefined [enabled by default]
In file included from /usr/include/python2.7/pyconfig.h:3:0,
                 from /usr/include/python2.7/Python.h:8,
                 from pymemcompat.h:10,
                 from _mysql.c:29:
/usr/include/x86_64-linux-gnu/python2.7/pyconfig.h:902:0: note: this is the location of the previous definition
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib/x86_64-linux-gnu -lmysqlclient_r -lpthread -lz -lm -lrt -ldl -o build/lib.linux-x86_64-2.7/_mysql.so
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
copying build/lib.linux-x86_64-2.7/_mysql_exceptions.py -> build/bdist.linux-x86_64/egg
copying build/lib.linux-x86_64-2.7/_mysql.so -> build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.7/MySQLdb/__init__.py -> build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.7/MySQLdb/release.py -> build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.7/MySQLdb/cursors.py -> build/bdist.linux-x86_64/egg/MySQLdb
creating build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/__init__.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/FIELD_TYPE.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/FLAG.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/ER.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/CLIENT.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/CR.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/REFRESH.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/times.py -> build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.7/MySQLdb/connections.py -> build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.7/MySQLdb/converters.py -> build/bdist.linux-x86_64/egg/MySQLdb
byte-compiling build/bdist.linux-x86_64/egg/_mysql_exceptions.py to _mysql_exceptions.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/release.py to release.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/cursors.py to cursors.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/FIELD_TYPE.py to FIELD_TYPE.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/FLAG.py to FLAG.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/ER.py to ER.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/CLIENT.py to CLIENT.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/CR.py to CR.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/REFRESH.py to REFRESH.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/times.py to times.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/connections.py to connections.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/converters.py to converters.pyc
creating stub loader for _mysql.so
byte-compiling build/bdist.linux-x86_64/egg/_mysql.py to _mysql.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/MySQL_python-1.2.2-py2.7-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
20:35:07 INFO | unzip -q -o -d '/usr/local/lib/python2.7/dist-packages/autotest/site-packages' 'dist/MySQL_python-1.2.2-py2.7-linux-x86_64.egg'
20:35:07 INFO | unzip '/usr/local/lib/python2.7/dist-packages/autotest/ExternalSource/atfork-0.1.2.zip'
Archive:  /usr/local/lib/python2.7/dist-packages/autotest/ExternalSource/atfork-0.1.2.zip
  inflating: atfork-0.1.2/setup.py
  inflating: atfork-0.1.2/PKG-INFO
  inflating: atfork-0.1.2/atfork/__init__.py
  inflating: atfork-0.1.2/atfork/stdlib_fixer.py
  inflating: atfork-0.1.2/atfork/tests/test_atfork.py
  inflating: atfork-0.1.2/atfork/tests/test_stdlib_fixer.py
20:35:07 INFO | '/usr/bin/python' setup.py build
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/atfork
copying atfork/__init__.py -> build/lib.linux-x86_64-2.7/atfork
copying atfork/stdlib_fixer.py -> build/lib.linux-x86_64-2.7/atfork
package init file 'atfork/tests/__init__.py' not found (or not a regular file)
creating build/lib.linux-x86_64-2.7/atfork/tests
copying atfork/tests/test_atfork.py -> build/lib.linux-x86_64-2.7/atfork/tests
copying atfork/tests/test_stdlib_fixer.py -> build/lib.linux-x86_64-2.7/atfork/tests
package init file 'atfork/tests/__init__.py' not found (or not a regular file)
20:35:07 INFO | '/usr/bin/python' setup.py install --no-compile --prefix='/var/tmp/tmpaniaRy'
running install
running build
running build_py
package init file 'atfork/tests/__init__.py' not found (or not a regular file)
package init file 'atfork/tests/__init__.py' not found (or not a regular file)
running install_lib
creating /var/tmp/tmpaniaRy/lib
creating /var/tmp/tmpaniaRy/lib/python2.7
creating /var/tmp/tmpaniaRy/lib/python2.7/site-packages
creating /var/tmp/tmpaniaRy/lib/python2.7/site-packages/atfork
copying build/lib.linux-x86_64-2.7/atfork/__init__.py -> /var/tmp/tmpaniaRy/lib/python2.7/site-packages/atfork
creating /var/tmp/tmpaniaRy/lib/python2.7/site-packages/atfork/tests
copying build/lib.linux-x86_64-2.7/atfork/tests/test_atfork.py -> /var/tmp/tmpaniaRy/lib/python2.7/site-packages/atfork/tests
copying build/lib.linux-x86_64-2.7/atfork/tests/test_stdlib_fixer.py -> /var/tmp/tmpaniaRy/lib/python2.7/site-packages/atfork/tests
copying build/lib.linux-x86_64-2.7/atfork/stdlib_fixer.py -> /var/tmp/tmpaniaRy/lib/python2.7/site-packages/atfork
running install_egg_info
Writing /var/tmp/tmpaniaRy/lib/python2.7/site-packages/atfork-0.1.2-py2.7.egg-info
20:35:07 INFO | rsync -r '/var/tmp/tmpaniaRy/lib/python2.7/site-packages/' '/usr/local/lib/python2.7/dist-packages/autotest/site-packages/'
20:35:07 INFO | unzip '/usr/local/lib/python2.7/dist-packages/autotest/ExternalSource/gwt-2.4.0.zip'

SICP CHAPTER 1 SECTION "NAMING AND ENVIRONMENT”

commandline session

$scm
SCM version 5e5, Copyright (C) 1990-2006 Free Software Foundation.
SCM comes with ABSOLUTELY NO WARRANTY; for details type `(terms)'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `(terms)' for details.
;loading /usr/share/slib/require
;done loading /usr/share/slib/require.scm
;loading /usr/share/slib/require
;done loading /usr/share/slib/require.scm
;loading /usr/lib/scm/Link
;done loading /usr/lib/scm/Link.scm
;loading /usr/lib/scm/Transcen
;done loading /usr/lib/scm/Transcen.scm
> (define a 2)
#
> (define aa 2)
#
> define a 2
(#@keyword . #<primitive-macro! #>)
> 2
> 2
> (define size 2)
#
> (define>> a 2)

;ERROR: "/usr/lib/scm/Iedline.scm": unbound variable:  define>>
; in expression: (define>> a 2)
; in top level environment.
;STACK TRACE
1; (#@let ((tail (#@lambda (c) (#@if (#@char? #@c) #@c (#@let* (( ...
2; (define>> a 2)

>

SICP Chapter 1 Section "Expressions"

commandline session

$scm
SCM version 5e5, Copyright (C) 1990-2006 Free Software Foundation.
SCM comes with ABSOLUTELY NO WARRANTY; for details type `(terms)'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `(terms)' for details.
;loading /usr/share/slib/require
;done loading /usr/share/slib/require.scm
;loading /usr/share/slib/require
;done loading /usr/share/slib/require.scm
;loading /usr/lib/scm/Link
;done loading /usr/lib/scm/Link.scm
;loading /usr/lib/scm/Transcen
;done loading /usr/lib/scm/Transcen.scm
> 121
121
> + 121
#
> 121
> + 121 1
#
> 121
> 1
> (+ 121 1)
122
>

nmap – Network exploration tool and security / port scanner

commandline session

$nmap --reason 127.0.0.1

Starting Nmap 6.00 ( http://nmap.org ) at 2013-09-06 21:58 IST
Nmap scan report for localhost.localdomain (127.0.0.1)
Host is up, received conn-refused (0.0013s latency).
Not shown: 995 closed ports
Reason: 995 conn-refused
PORT     STATE SERVICE REASON
22/tcp   open  ssh     syn-ack
25/tcp   open  smtp    syn-ack
111/tcp  open  rpcbind syn-ack
389/tcp  open  ldap    syn-ack
1094/tcp open  rootd   syn-ack

Nmap done: 1 IP address (1 host up) scanned in 0.39 seconds
$

file — determine file type

commandline session

$ls
faq  favicon.ico  index.html  kernel.css  mirrors  pub	robots.txt
$file kernel.css
kernel.css: ASCII text
$file -l | head
Set 0:
Binary patterns:
Text patterns:
Set 1:
Binary patterns:
Text patterns:
Set 0:
Binary patterns:
Strength = 340 : sc68 Atari ST music []
Strength = 340 : T64 tape Image []
$file -l | tail
Strength =  28 : exported SGML document text []
Strength =  20 : Java source [text/x-java]
Strength =  20 : script text executable []
Strength =  18 : a []
Strength =  17 : a []
Strength =  12 : Perl5 module source text []
Strength =   2 : Tcl script []
Set 1:
Binary patterns:
Text patterns:
$