I had a horrible memory corruption bug in our IMS code the other day and had to track the little guy down. First thing I noticed on solaris is that the default core setup doesn’t name the core file with a pid for example. This means that whenever a process in a multiprocess app cores, it will overwrite the core file. So you will only have the last core file (the last process to crash) available to work with.

The first thing you want to do is configure the core file naming rule, for example:

coreadm -i core.%f.%p

will set the core file for a kamailio process crash: core.kamailio.12345. You will therefore have a core file per process that crashes

From here you can use conventional GDB tools to analyze and track down your bug.

One thing I found very useful was analysing the memory using:
x/64hw 0x1234abcd (this will print 64 bytes of mem using hex words from the address 0x1234abcd).

Happy Debugging ;)

So today I was checking out a new version of Asterisk and noticed after install that playing of the gsm sound (prompt) files sounded muffled and of very poor quality. Apparently this is a problem with optimisations in GCC > 4.2. To combat, recompile the gsm codec with -O2 option. On mine, by default gcc was using -O6.

Recompiling the codec and dumping in Asterisk’s lib directory sorted the problem out nicely ;)

If you’ve ever dablled with the Kamailio/siprouter project you will notice that there are 2 different flavours. One for Kamailio (formerly OpenSER) and one for SER (the original project started many years back). Personally I prefer the Kamailio flavour but by default the siprouter project defaults to SER flavour.

Here’s what to do to change before you build:

make proper
make FLAVOUR=kamailio cfg
make
make modules
make install

Recently I was given developer access to an open source project and I needed to be able to use GIT. I am accustomed to SVN and have zero experience with GIT. So the basics.

First we need to clone a git repo:

git clone ssh://user.name@git.sip-router.org/sip-router

This will clone by default the master/trunk(svn) branch. Now we need to set some options to tell GIT a little about ourselves:

git config --global user.email "email@domain"
git config --global user.name "name surname"

Then we can make changes on the repo and commit locally with:

git commit -a | filename

finally, to commit remotely, we need to push the changes:

git push origin master:master

1. A useful preprocessor def to include/exclude code on a Solaris compile. This will support both gcc and Sun CC

#if !defined (__SVR4) && !defined (__sun)

2. Don’t use s_addr as a variable name in your code. It is defined as a macro on Solaris

#define   s_addr  _S_un._S_addr

Ever wondered why you only get bold and underline highlighting in Solaris?

make sure your TERM env variable is set to xterm-color

export TERM=xterm-color

To make this permanent, set it in your /etc/profile

Here is a nice .vimrc file for coding:

syntax on
set tabstop=3
set ruler
set nocompatible
set pastetoggle=<f11>
set nopaste
set autoindent
set shiftwidth=4
set vb t_vb=
set nobackup
set history=50
set expandtab
set showfulltag
set showmatch
autocmd FileType make set noexpandtab
set viminfo='20,\"1000
vnoremap p <Esc>:let current_reg = @"<CR>gvs<C-R>=current_reg<CR><Esc>
if has("autocmd")
   autocmd BufReadPost *
      \ if line("'\"") > 0 && line("'\"") <= line("$") |
      \ exe "normal g`\"" |
      \ endif
endif
set wmh=0
set wmw=0