Segmentation Fault


OS extends its physical memory by using virtual memory which is implemented using a technique called paging.
Paging is another form of swapping between HDD and Physical Memory.
If application requests a page in memory and it could find it then a Page Fault occurs.
If the address of the page requested is invalid then Invalid Page Fault occurs which causes the program to abort.

What is segmentation fault?

In operating systems that use virtual memory, every process is given the impression that it is working with large, contiguous sections of memory. In reality, each process’ memory may be dispersed across different areas of physical memory, or may have been paged out to a backup storage (typically the hard disk). When a process requests access to its memory, it is the responsibility of the operating system to map the virtual address provided by the process to the physical address where that memory is stored. The page table is where the operating system stores its mappings of virtual addresses to physical addresses.

The page table lookup may fail for two reasons. The first is if there is no translation available for that address, meaning the memory access to that virtual address is invalid. This will typically occur because of a programming error, and the operating system must take some action to deal with the problem. On modern operating systems, it will send a segmentation fault to the offending program.

The page table lookup may also fail if the page is not resident in physical memory. This will occur if the requested page has been paged out of physical memory to make room for another page. In this case the page is paged to a secondary store located on a medium such as a hard disk drive (this secondary store, or “backing store”, is often called a “swap partition” if it’s a disk partition or a swap file, “swapfile”, or “page file” if it’s a file). When this happens the page needs to be taken from disk and put back into physical memory.

Common causes segmentation fault:

The following are some typical causes of a segmentation fault:

Attempting to execute a program that does not compile correctly. Some compilers will output an executable file despite the presence of compile-time errors.

  •     Dereferencing NULL pointers
  •     Attempting to access memory the program does not have rights to (such as kernel structures in process context)
  •     Attempting to access a nonexistent memory address (outside process’s address space)
  •     Attempting to write read-only memory (such as code segment)
  •     A buffer overflow
  •     Using uninitialized pointers

When a Page Fault occurs, OS does the following:

  •     Determine the location of the data in auxiliary storage.
  •     Obtain an empty page frame in RAM to use as a container for the data.
  •     Load the requested data into the available page frame.
  •     Update the page table to show the new data.
  •     Return control to the program, transparently retrying the instruction that caused the page fault.


source : wikipedia and webopedia

Install MySQL plugin for Newrelic in a Minute

To use this plugin, you must have:

  • a Java Runtime Environment (JRE) of 1.6 or higher
  • at least one database to monitor (MySQL 5.0 or higher)
  • a New Relic account

New Relic Platform Installer (NPI) is a simple, lightweight command line tool that helps you easily download, configure and manage New Relic Platform Plugins

Plugin for Generic Linux OS (OS = Opensuse)

LICENSE_KEY=4eeeeeeeeeeeeeeeeeeeeeeee2e bash -c "$(curl -sSL"
npi install com.newrelic.plugins.mysql.instance

Configuration File

#vim ~/newrelic-npi/plugins/com.newrelic.plugins.mysql.instance/newrelic_mysql_plugin-2.0.0/config/plugin.json


"agents": [
"name" : "Host Name on Newrelic UI",
"host" : "localhost/RDS ENpoint",
"metrics" : "status,newrelic",
"user" : "DB_USER_NAME",
"passwd" : "DB_PASSWORD"

Start Plugin:

#cd /root/newrelic-npi/plugins/com.newrelic.plugins.mysql.instance/newrelic_mysql_plugin-2.0.0
#java -Xmx128m -jar plugin.jar



GitHub =
Plugin Home Page =

Install Newrelic Agent for PHP in a 1 minute

Install NewRElic PHP Plugin for Amazon LINux
Create newrelic account on web and get the License number.
sudo rpm -Uvh

sudo yum install newrelic-php5
sudo newrelic-install install

vim /etc/php.ini
/etc/init.d/httpd restart

Install System Monitoring NewRelic

rpm -Uvh

yum install newrelic-sysmond
nrsysmond-config --set license_key=4b106d772c3115f649

/etc/init.d/newrelic-sysmond start