Kernel Panic

Kernel Panic is a term used to denote when a OS cant boot properly or crashed because of a fatal error. This could be because of many reasons like unsupported hardware or missing/corrupted drive or because of unstable updates.It is equivalent of Windows Blue Screen error for UNIX and UNIX based systems.

Kernel Panic sometimes might be caused because of Kernel Oops(In case of error, Kernel will kill the offending process and continue to run). This can be identified with the call trace stack displayed at the time of startup.In these cases, users will be displayed with the grub menu.

Error1: Simplest reason for this panic might be because of less space in /boot folder.Easiest way to fix this issue will be to boot the old kernel from the available list and users can purge old kernels through

sudo apt-get autoremove

and also remove unstable updates.

Error2: “Kernel Panic – not syncing: VFS: Unable to mount root fs on unknown-block(0,0)”
In this case, grub update is needed. Boot old kernel(if available) or use Live CD to boot and run the following commands from any one of the below approach.

Fix 1: Run

dpkg –configure -a

This will update the initramfs hook and fix the broken kernel.
Fix 2: Run

update-initramfs -u -k version


Fix 3: This fix can be done when grub is looking in a different path. Find the correct the filesystem where grub is installed using following commands in GRUB prompt(Shift +C during startup),

ls # Should show your drives and partitions hd0,1=sda1
ls (hd0,1)/ # Should include ‘vmlinuz’ and ‘initrd’
ls (hd0,1)/boot/grub # Should see a lot of *.mod files

and then install grub with following commands after booting old kernel/using LiveCD,

sudo mount /dev/sda1 /mnt
sudo grub-install –root-directory=/mnt /dev/sda

Note: 2nd line should have the partition number.

About pages in Mozilla Firefox

Mozilla has hidden various configuration and diagnostic information in its internal about pages. Some of the important about pages are ,

1. About:Mozilla
This page contains a verse from the Book of Mozilla.This was first introduced in 1994.
2. About:Config
The contents of this page has already been discussed here.

3. About:Crashes
You’ll find Firefox’s crash reports on the about:crashes page. Click a crash report and it’ll be submitted to Mozilla, where you can view information about it.If you’re struggling with a crash, you can use the information here to figure out what the problem is. Googling up some of the crash messages might help you determine the problem.

4. About:Permissions
Firefox includes website-specific permissions, which you can manage for a single website by right-clicking on a web page selecting View Page Info. About:permissions shows you all this information in one place.

5. About:About
Here you can find all the about pages in Firefox. Try out each one. It will help you to use Firefox efficiently.

Dive Deep into CPP: Abstract Class and Pure Virtual Function

Pure virtual function are virtual function with no definition.


virtual void func()=0;

Class with atleast one pure virtual is made as abstract class. Classes that inherit the abstract class must provide the definition to the pure virtual function.

What happens when we create a pure virtual function ?

When we create a pure virtual function in abstract class, we reserve slot for that function in the VTABLE(virtual table, maintained by the compiler), but doesnt put any address in that slot. So the VTABLE will be incomplete.Since the VTABLE for the abstract class is incomplete, compiler will not allow the creation of the object and will throw an error.

Pure Virtual Definitions:

These pure virtual functions can have definition in abstract class, which we want all the derived class to have. These definitions should be provided outside the class definition.

What does pure virtual function mean ?

When a function is declared pure virtual function, it cannot be called dynamically through a virtual dispatch mechanism.But it can be called statically without virtual dispatch. So, yes. Pure virtual functions can have definition. But it makes the class abstract without completing the VTABLE.

Dive Deep into CPP: Copy Constructor

Copy Constructor is usually invoked by passing reference to the old object of a class to a newly created object of the same class. Compiler by default provide a copy constructor to a class even if you didnt provide one. When the Copy Constructor is invoked either by calling copy constructor during declaration or using an assignment operator, the constructor will get the reference and then it simply assigns it to the new object using the assignment operator.So Copy Constructor is implemented by overloading the assignment operator.

Why program runs into an infinite loop , if copy constructor is invoked by value ?

If we didnt pass the old object by reference and if we pass by value, in the copy constructor it will be assigned to the new object by an assignment operator and the compiler will inturn call the copy constructor again and then assignment operator and so on in an infinite loop.

Dive Deep into CPP: Types of collaboration between classes

Message to self.Calling m1 from m2 where they are the methods of the same class. Preferred relationship is “has-a “.We will be using “this” keyword for invocation. Which means compiler already created an object of the same class within itself.

Base derived
We can call the method of base class from derived using “super” or “base” keywords which are the objects of base and it is created within the derived class. So we use “is-a” relation but it is implemented through “has-a” relation. But if there is no “is-a” relation between the base and derived class, then those objects won’t be created. So its an equalizer

Accessing from sibling class. Preferred relation  is “has-a”.

Peer to peer
Preferred relationship is “has-a ”

Generalization is having both the interface(type contracts etc) and the implementation of the base class.
Realization is having only the interface of the base class and creating their own implementation for the methods in the base class.
In “has-a” relationship, we can use only the  implementation of the class, but not its interface.
Finally, we can say  generalization =realization +has a
So generalization which is tightly coupled can be replaced with realization and association relationships which will make the classes loosely coupled.This will give the flexibility we need and will give us a good clean design .

Dive Deep into CPP : Constructors

You can use constructor with initialization list in addition to the default ways. You cant use initialization list with arrays,list, vector etc. Also static variables cant be initialized using this method. Initialization of reference variable and const variable can only be done through initialization list. It cant be done through constructor body. Body of the constructor believes that the variables have been initialized and so it assigns. Initialization is the first assignment. const and reference variables can be initialized only once. So it must be initialized through initialization list. Static members do not belong to one object of that class. So it cant be initialized through initialization list. But can be done through body, because it only assigns.

A(): x(0),y(0)

Constructor is overloaded using initialization list  like

A(int x_=0) : x(x_)

Class with private constructor cannot be inherited. It can be instantiated by friends of the class or through a public static function.Classes with protected constructors cannot be instantiated outside. Can only be used in inheritance. It will be like abstract base class when virtual functions are not feasible. Base class can be instantiated from outside by using copy constructor. Because it is provided by default by the compiler. So it is partial abstract class. If you want to make it as pure abstract class, make all constructor as protected.
To set a field read only, use constructor to initialize the variable and remove the setter function.

Dive Deep into CPP : Inheritance and Access Specifier

When a class inherits a base class with private variables, private variable is also inherited but it is invisible to the derived class. We can access the private variables using the public setter and getter method implemented in the base class.
So the size of the derived class will be same of the base class if it doesn’t have any members. It is similar to member functions.