Wednesday, October 28, 2015

gdb unable to find shared symbols

This primarily happens when you trace your gdb to an unknown terrain - i.e. you enter part of the shared library's code whose symbols have not been loaded by gdb yet.

I encountered this problem while building a device mapper library. Even though I spent a couple of hours going through the Makefile, ensuring that I was configuring the library using the --enable-debug option, when I ran the library with gdb and traced to the part of the code located in the library using 'n' and 's' commands (Please read what they are meant for if you don't have an idea about them), I kept falling into the same pit - no debug symbols found.

I then came across this blog

Which basically stated that all shared libraries loaded by gdb for a particular run can be viewed using the following command:

(gdb) info sharedlibrary
From                To                  Syms Read   Shared Object Library
0x00007ffff7dd9aa0  0x00007ffff7df5590  Yes         /lib64/
0x00007ffff7b78330  0x00007ffff7bc320f  Yes      * /lib/
0x00007ffff77c34f0  0x00007ffff7916354  Yes         /lib/x86_64-linux-gnu/
0x00007ffff759e190  0x00007ffff75a1167  Yes         /lib/x86_64-linux-gnu/
0x00007ffff7383a90  0x00007ffff7390c41  Yes         /lib/x86_64-linux-gnu/
0x00007ffff707b5a0  0x00007ffff70ecc61  Yes         /lib/x86_64-linux-gnu/
(* No debug symbols found)

This made me realise that /lib/ is the library for the default devicemapper package and that my own library with all debug symbols was not being read by gdb at all!

To correct this, I simply installed my library to override the existing /lib/ library. Rerunning gdb now gives me access to all symbols in my library!

(gdb) info sharedlibrary
From                To                  Syms Read   Shared Object Library
0x00007ffff7dd9aa0  0x00007ffff7df5590  Yes         /lib64/
0x00007ffff7b78330  0x00007ffff7bc320f  Yes         /lib/
0x00007ffff77c34f0  0x00007ffff7916354  Yes         /lib/x86_64-linux-gnu/
0x00007ffff759e190  0x00007ffff75a1167  Yes         /lib/x86_64-linux-gnu/
0x00007ffff7383a90  0x00007ffff7390c41  Yes         /lib/x86_64-linux-gnu/
0x00007ffff707b5a0  0x00007ffff70ecc61  Yes         /lib/x86_64-linux-gnu/

Go nuts with gdb!

Tuesday, December 9, 2014

Gesture Recognition for your Computer /*from scratch*/

Step 1.

What you need:

Virtual Box
Virtual Box Extension Pack
Ubuntu VM (tried it on 12.04)

Need to install Extension Pack. Then goto devices -> USB -> enable Camera/unknown device

Note: I am trying this using integrated camera in Lenovo T420. Please check if camera is easily detectable from Windows Host. If not, then fix that first.

Once the camera has been attached to the Ubuntu VM inside Virtual Box, check the camera settings using cheese.

Step 2.

What you need.

install libgtk2.0-dev and pkg-config.
Open CV source code. Install directly from the source webpage:

Step 3.

All the Hand Gesture code in the world that you will need to get it going :D

Wednesday, August 14, 2013

Creating an ISO Image from CD/DVD in Ubuntu using terminal

First of all, know where your CD Drive is mounted. You can run the following command to do the same:

shehbaz@Augustus:~$ mount | grep sr
/dev/sr0 on /media/UDF Volume type udf (ro,nosuid,nodev,uid=1000,gid=1000,iocharset=utf8,

The CD / DVD is mounted in /dev filesystem in linux. running the mount command itself could help you to figure out the location where CD / DVD is mounted.

Next, you could do the following

cat /dev/sr0 > dumb.iso

which, as the name suggests, is a dumb way of creating the iso file.

why you ask? because, there is no error checking while reading from the Disk (/dev/iso) and writing to our iso image file. Here, I introduce before you the command


Which stands for read - optical - media : your disk.

This command is available in the package wodim and can be installed using

sudo apt-get install wodim

readom not only creates a new, error-free iso image, but also retries reading from the cd drive in case the drive is busy / error occoured in copying a specific block/sector.

readom dev=/dev/sr0  f=smart.iso

Note : If you get the following error:

shehbaz@Augustus:~$ readom dev=/dev/sr0 f=smart.iso
Error trying to open /dev/sr0 exclusively (Device or resource busy)... retrying in 1 second.
just eject the CD Drive, and reinsert it, and close any auto msg boxes that pop up.

readom will ensure that the final CD/DVD iso image that is created is authentic, which would help you save lot of time playing around with erroneous iso image files.

Wednesday, August 7, 2013

How to Kill the Init Process (And recover from It)

What happens when we kill the init process?

Question 1 : Why the hell would you kill an init process?
Answer 1: To know what happens if someone,anyone tries to kill the init process
Answer 2: Inquisitiveness (My case!)

To see for yourself, please try the following:

1. Open a terminal
2. Type kill -9 [pid of init process]

The pid (or process id) of the init process can easily be obtained using the


command, or the following command

ps -afx | grep init

I think it is 1 for all the processes, but try the above two commands just to be sure.

Now, after killing the init process, reboot your system.

Rebooting will cause a kernel panic!

Cause :

Kernel panics because it tries to initialize the init process after initializing the kernel processes. However, it is unable to do so (because during previous shutdown, init process did not comprehensively free all user applications, which would lead to clearing all kernel data structures)

Note that some of these data structures would be maintained in the swap space (in the disk), also, the super block (in your bootable device i.e. disk) may get corrupted due to improper shutdown in the previous boot.  

Solution to rectify this problem :

In my case, using a live USB, I performed a memory check and a disk check. Ubuntu Live USB showed me two files in the superblock in the bootable device [HDD /dev/sda8] had been corrupted. In order to rectify these files, I did the following

sudo fsck /dev/sda8

A simple filesystem check was sufficient to recover my bootable device, without any data loss.

To check my file systems normal operation, I mounted the filesystem (/dev/sda8) using the Live USB itself. And it worked like a charm.

Rebooted the system, removed the USB, and my HDD was able to successfully boot my laptop. :)

Wednesday, July 17, 2013

Kerberos, LDAP and NFS

Recently I took a project to setup a SSO (Single Sign On) System for a small lab. We had a set of 25 computers, each with the following configuration:
  • i3 processors (two cores)
  • 500 GB HDD
  • 4GB RAM
We had to install Fedora 19 in each of these machines, along with some standard softwares.

The Incremental Model:

1st architecture:

1 Server, the master server, who shall be thus referred to as (cnl stands for computer networks lab, for the more inquisitive readers). is the realm/ring that we label all the computers in the lab with.

Day 1:

Setting up Server, DHCP Hostname.
  1. We setup a single server, a Debian OS. (We do that because of an innate bias towards Debian OS, also due to over familiarity with using Ubuntu. :P)
  2. We configure the servers dhcp client name (Note that all the machines in the lab are dhcp clients, including our Kerberos server, LDAP Server). for this we need to make changes in /etc/hosts file.
  3. We decide to name the realm . (A better extension would have been cnl.lab, but that is something we are going to ignore).
  4. Hence the name assigned to the server ends with The hostname is now (This can be checked using the command hostname -f )

Setting up the Kerberos Server.
I followed this to setup the Kerberos Server. Its pretty much self explanatory. Few changes :

  1. During installation of krb5-admin-server ,  there are a few default realm names, passwords, and principal users that are asked for. They are also self explanatory, just keep in mind to end the hostname with
  2. My /etc/krb5.conf file looks like this: 

kdc =
admin_server =
default_domain =

[domain_realm] = CNL.NET

default_realm = CNL.NET
dns_lookup_realm = false
dns_lookup_kdc = false

profile = /etc/krb5kdc/kdc.conf

default = FILE:/var/log/kerberos/krb5libs.log
kdc = FILE:/var/log/kerberos/krb5kdc.log
admin_server = FILE:/var/log/kerberos/kadmind.log

Kerberos Architecture defines AS and TGS as two separate entities. In our setup, they are the same host :

Troubleshooting and Testing The server:

principal :  any identity that asks for a ticket is called a principal [READ THIS]. For our usage, we setup the following principals.

  1. harshal/
format of a principal:


Note that for shehbaz, the default non-admin instance is taken.

some useful krb server commands:

server# kadmin -p krbadmin/admin
kadmin: listprincs
kadmin: addprinc root/admin
kadmin: addprinc shehbaz
Kerberos testing

Create ticket
server# kinit shehbaz Password for shehbaz@CNL.NET:
Verify ticket

server# klist
# klist Ticket cache: FILE:/tmp/krb5cc_0 Default principal: shehbaz@CNL.NET
Valid starting Expires Service principal 09/01/11 00:56:58 09/01/11 10:56:58 krbtgt/CNL.NET@CNL.NET renew until 09/02/11 00:56:53

Day 2

1. Options to install Fedora on the Client Machine are here.
2. copy the /etc/krb.conf file from the server to the client machine.

Installing Kerberos clients for Debian and Fedora

Setting up LDAP

Running into a lot of issues right now. Messed up slapd configuration files. restoration took a lot of effort.
[TODO] Read up on ldap before trying to configure it.

Day 3 

Continuing with LDAP. Reading this and this to configure LDAP.

LDAP terminologies given here                         

Day 4

Sweet Success!! :D

After a lot of reading, understood a bit of LDAP structure. Refer this this and this for a more detailed understanding.

Heres are some interesting things that one should know:
  1. LDAP is basically a database in the form of a tree, just like a phonebook or yellow-pages.
  2. It is a database structure optimized for reads rather than writes, so you basically make lots of searches and less number of additions/deletions/modifications. 
  3. Three things: schema , objectclass , attributes :
    schema is the template on which the entries (actual physical elements of the database are configured). these are located in /etc/ldap/schema folder. these are of three types : structural, abstract, and auxillary.
    objectclass is a label on the schema. first node in the tree is top. other objectclasses inherit top and have other child objectclasses.
    attributes are properties of the objectclass, some are mandatory, while others are optional.                        
  4. Main operations performed on an ldap database ldapadd, ldapsearch, ldapmodify.
  1. There are a lot of objectclasses already available (defined in ldap), like person, organization etc.
  2. slapd.conf is outdated, now they use OLC (Online control) (cn=config) file for ldap support. Though support for slapd.conf is still supported.

ldapadd -H ldap:// -x -D "cn=admin,dc=cnl,dc=net" -f demo.ldif -w <password>

My sample demo.ldif file:

dn: ou=admin,dc=cnl,dc=net
objectclass: organizationalUnit
ou: admin

dn: ou=student,dc=cnl,dc=net
objectclass: top
objectclass: organizationalUnit
ou: student

dn: cn=harshal,ou=admin,dc=cnl,dc=net
objectclass: top
objectclass: person
objectclass: organizationalPerson
sn: Muknak
cn: Harshal Muknak
ou: admin

dn: cn=shehbaz,ou=student,dc=cnl,dc=net
objectclass: top
objectclass: person
objectclass: organizationalPerson
sn: Jaffer
cn: Shehbaz Jaffer
ou: student

NOTE that I did not have to add any schema definitions for creating the ldap directory structure (i.e. adding objectclass). I have used inbuilt schemas like person and organizationalUnit.

For LDAP Clients, on Fedora use this.


Day 6

Setting up NFSv4.

/etc/exports file:

/media/student        *(rw,nohide,no_root_squash,no_subtree_check,sync,fsid=0)

mount command:

sudo mount -v -t nfs4 /home/student

alternatively, for mounting on boot, add this to the end of /etc/fstab of the client: /home/students nfs4 defaults       0 0

Note that the ip mentioned is the server IP. We mounted the whole '/' directory, however, only /media/student (the mountable directory on the server) gets mounted.

Follow the above statements as-is, or you will get lots of issues (No route to host etc).

Tuesday, July 16, 2013

Installing Fedora 19 using LiveUSB

I am trying to install Fedora 19 on one of the hosts. There are a lot of issues that I ran into, which I have documented here.

1. Creating A Live USB using Unetbootin

I am using a Debian Wheezy to create a Fedora 19 bootable USB. Unetbootin for Debian Wheezy has support for building only Fedora 16 x86_64 OS, but we are proceeding with choosing Fedora 16 x86_64 option and installing a Fedora 19 disk Image.


After creating the Live USB, on boot the computer gives the following message:

No DEFAULT or UI configuration directive found!

To correct this, I formatted the pendrive using gparted   and created a FAT32 filesystem.

Install packages:

sudo apt-get install gparted dosfstools

Run gparted

sudo gparted

select the USB from devices menu (/dev/sdb in my case). and create a FAT32 filesystem for my USB.

Run unetbootin

sudo unetbootin

Select the appropriate Fedora 19 x86_64 iso image and install it on USB Image.

Live USB is ready.

The Fedora Setup

After choosing the Run Default option from UnetBootin Screen, I divided the fedora partitions into 3 parts:
Label Type Mount Point Size
LinuxLocalFolder ext4 / 380 GB
WindowsLocalFolder ext4 /var 40GB
root /home ext4 20GB
Swap Space swap swap 20GB

LVM (Logical Volume Mount)

Something new, unlike previous Primary Partitions (4 in number ) and countless Logical Partitions, Fedora 19 gives us LVM, where we can just assign each partition the label LVM, and Fedora itself configures what to take as a primary partition and what to take as a logical partition.

Thursday, May 30, 2013

Tweaking tcp port - Improving performance of network intensive applications over high latency network

Building an application over a low latency network could give you very good performance, but sometimes over a high latency network, read() or write() system calls could be a cause of bottleneck for the applications performance.

Consider a network intensive application running on server A. This server continuously generates log and sends it over the network to another server B . Now, server B may be slow (low computation power) or the network may have high error/ latency, due to which the write buffer of A gets saturated. As a result server A stalls (write buffer of A is filled, but B is not ready to read the data yet).

By default in the linux kernel, each tcp port is configured with around 64-80KB read/write buffer.

This can be seen using the command :

$sudo su
#sysctl -a | grep net | grep mem

net.ipv4.tcp_mem = 93132        124179  186264
net.ipv4.tcp_wmem = 4096        16384   3973728
net.ipv4.tcp_rmem = 4096        87380   3973728

The numbers represent the minumum, default and maximum memory allocated to every tcp port  that is created on a machine.

For solving our current problem, all we need to do is increase the default port size to a larger value. Increasing the memory associated with a port can be done as follows:

#sysctl -w net.ipv4.tcp_rmem='4096        3000000   3973728'
#sysctl -w net.ipv4.tcp_rmem='4096        3000000   3973728'

NOTE: This change gets reflected on every port that is created on the server. Hence, one should be careful not to increase the default port size to a very large value, as each new connection would result in higher memory usage.