Asterisk 13.9.1 crash centos 6


I have followed the steps at to install v 13.9.1 on a Cent OS 6 system. The “configure” and “make , make install , make config” steps completed successfully.
However when start it via “service asterisk start” , I see in /var/log/messages :

Jun 25 15:41:22 host kernel: [33614.496585] asterisk[30962] trap invalid opcode ip:5e4753 sp:7ffe2214c0e0 error:0 in asterisk[400000+34d000]
Jun 25 15:41:22 host abrt[30963]: Not saving repeating crash in '/usr/sbin/asterisk’
Jun 25 15:41:22 host abrt[30963]: Saved core dump of pid 30962 to core.30962 at /tmp (1511424 bytes)

This keeps on repeating until I stop the service.

If I try to start with “asterisk -vvvvvc” then it just shows “Illegal instruction (core dumped)”…

I tried to recompile source with flags “DONT_OPTIMIZE , BETTER_BACKTRACES” enabled. When I looked at gdb debugging info, it showed the first error (#0) as -

(gdb) bt full
#0 0x00000000005e4753 in timesub (timep=0x7fffffffb970, offset=-14400, sp=0x99b860, _
_ tmp=0x7fffffffbbb0) at stdtime/localtime.c:2010

_ lp = 0x7fffffffb990_
_ tdays = 176_
_ idays = 0_
_ rem = 68885_
_ y = 2016_
_ ip = 0x303918e120_
_ corr = 0_
_ hit = 0_
_ i = -1_
_ seconds = 10072216_

I am not sure what could be the problem here. Any help is appreciated.

You’ve built on a virtual machine. Some virtual machines incorrectly specify the processor capabilities. Rather than using the machine architecture specification that tries to generate optimal code, you need to force a more general architecture on the configure step. Sorry I can’t remember the recommended choices for this.

I figured this out - had to disable to “Build Native” flag also… Asterisk starts successfully now…

It is not a problem with virtual machines reporting the cpu incorrectly. It is a problem with the way the default compiler flag interprets them.

Disabling Build Native flag will only compile for basic x86 instructions.

Using -mtune=native is the most optimal way I have found around the problem. This should be the compiler default imo. The Asterisk developers have a different opinion and feel that -march=native is a better default.

Here are the differences between the 2 compiler flags as described on the website.

selects the CPU to tune for at compilation time by determining the processor type of the compiling machine. Using -mtune=native will produce code optimized for the local machine under the constraints of the selected instruction set. Using -march=native will enable all instruction subsets supported by the local machine (hence the result might not run on different machines).

The config command to get around the problem in the most optimal way is:

./configure CFLAGS='-g -O2 -mtune=native'