Segmentation fault In Linux

A segmentation fault is a particular error condition that can be occur during the operation of computer software.A segmentation fault occurs when a program attempts to access a memory location that is not allowed to access, or attempts to access a memory that is not allowed.For example attempting to write a read only location or to overwrite to the memory where a part of operating system is there.

On Unix/Linux-like operating systems, a process that accesses invalid memory receives the SIGSEGV signal. Segmentation faults are commonly referred to as segfaults. Here is some example that create segmentation faults.

int main()


char *str = “india”;

*str = ‘H’;

return 0;


When the program containing this code is compiled, the string “india” is placed in the section of program marked as read only. when loaded the OS places it with other string and constant data in a read only segment of memory. when executed ,the variable str is pointed to that string location and attempts to write ‘H’ into the memory which cause segfaluts.

Some of the common mistake which leads segfault are given below

  • Dereferencing NULL
  • Dereferencing an uninitialized pointer
  • Dereferencing a pointer that has been freed or deleted in c++ or that has gone out of scope
  • Writing off end of the array

Posted in Linux. 1 Comment »

CSQL as Multiple bidirectional cache nodes for single data source

CSQL Cache is an open source high performance, bi-directional updateable data caching infrastructure for any disk residence database that sits between the application process and back-end to provide unprecedented high throughput to your application.


CSQL cache accelerate application performance at the data tier by sitting in the clustered middle tier servers . In multiple bidirectional cache, most frequently used table are cached to CSQL which is connected to the clustered application, by the table loader module. Any change made in application layer directly reflects to all other CSQL cache nodes as well as target database. For any kind of DML operation on non cached table, CSQL provides gateway to directly access that table from target database. Application doesn’t have any information whether their operation is held at CSQL or target database.

Any changes in target database on cached table is propagated to all CSQL cache nodes so that application connected to any CSQL node gets consistent data . To achieve this, CSQL maintains a log in target database which keeps track of all operation on cached tables as well as number of cached nodes running currently. Triggers are installed in the target database for all the DML operations on cached table to generate log entires in the log table.

Bi-Directional Cache Settings for MySQL as target database

Before start for Bi-Directional setting make sure that target database as MySQL ,Unixodbc and mysql-connector are installed.If not,then install first.

Let us consider there are two CSQL cache node and a target database as MySQL .To set multiple Bi-Directional caching, First create the table in MySQL to hold the log records using the SQL statement below using mysql tool or isql tool.

CREATE TABLE csql_log_int (tablename CHAR(64), pkid INT, operation INT, cacheid INT, id INT NOT NULL UNIQUE AUTO_INCREMENT) engine=’innodb’;

Make changes in csql.conf file CACHE_ID = 1 for one cache node and CACHE_ID = 2 in other cache node and make sure that CACHE_TABLE , ENABLE_BIDIRECTIONAL_CACHE are set to true . Again DSN should set to myodbc3 for MySQL.

Lets say for a cached table p1 with primary key f1 ,write a trigger(trigger.sql) as below

use test;
drop trigger if exists triggerinsertp1;
drop trigger if exists triggerupdatep1;
drop trigger if exists triggerdeletep1;

create trigger triggerinsertp1
Insert into csql_log_int (tablename, pkid, operation,cacheid )values (‘p1’, NEW.f1, 1,1);

Insert into csql_log_int (tablename, pkid, operation,cacheid )values (‘p1’, NEW.f1, 1,2);
create trigger triggerupdatep1
Insert into csql_log_int (tablename, pkid, operation, cacheid ) values (‘p1’, OLD.f1, 2,1);
Insert into csql_log_int (tablename, pkid, operation,cacheid ) values (‘p1’, NEW.f1, 1,1);

Insert into csql_log_int (tablename, pkid, operation, cacheid ) values (‘p1’, OLD.f1, 2,2);
Insert into csql_log_int (tablename, pkid, operation,cacheid ) values (‘p1’, NEW.f1, 1,2);
create trigger triggerdeletep1
Insert into csql_log_int (tablename, pkid, operation, cacheid )values (‘p1’, OLD.f1, 2,1);

Insert into csql_log_int (tablename, pkid, operation, cacheid )values (‘p1’, OLD.f1, 2,2);

Here for different table replace table name with p1 and primary field name with f1.

After writting the trigger.sql as per requirement execute it as below

$ mysql -u root -p <trigger.sql

Now start CSQL server by csqlserver -c and execute csql -g in both cache nodes . Check by DML operaton in target and CSQL cache node multiple Bi-Directional caching.

Product Page

free invisible web counter