pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

asterisk16: build native results in broken binaries under under certain circumstances



Hello together,

last night I stumbled across a funny effect that might be interesting for one or the other Asterisk user as well.

Under certain circumstances the pkgbuild of Asterisk creates binaries that are not executable on other computers of the same upper architecture. This can be recognized by the fact that Asterisk crashes with "Illegal Instruction" at startup.

A typical backtrace looks like this:

```
Starting program: /usr/pkg/sbin/asterisk

Program received signal SIGILL, Illegal instruction.
0x00000000005d43cd in cfmtime_new (who_asked=0x624222 "", filename=0x7f7fff3bccb0 "/usr/pkg/etc/asterisk/asterisk.conf")
    at config.c:1567
1567    config.c: No such file or directory.
(gdb) bt
#0 0x00000000005d43cd in cfmtime_new (who_asked=0x624222 "", filename=0x7f7fff3bccb0 "/usr/pkg/etc/asterisk/asterisk.conf")
    at config.c:1567
#1 config_text_file_load (database=<optimized out>, table=<optimized out>, filename=<optimized out>, cfg=0x70384d489000, flags=..., suggested_include_file=0x624222 "", who_asked=0x624222 "") at config.c:2147
#2  0x00000000005d3453 in ast_config_internal_load (
filename=filename@entry=0x8d3700 <cfg_paths+11264> "/usr/pkg/etc/asterisk/asterisk.conf", cfg=cfg@entry=0x70384d489000, flags=flags@entry=..., suggested_include_file=suggested_include_file@entry=0x624222 "",
    who_asked=who_asked@entry=0x624222 "") at config.c:3142
#3 0x00000000005d6219 in ast_config_load2 (filename=0x8d3700 <cfg_paths+11264> "/usr/pkg/etc/asterisk/asterisk.conf", who_asked=who_asked@entry=0x624222 "", flags=flags@entry=...) at config.c:3163
#4  0x0000000000510e71 in load_asterisk_conf () at options.c:232
#5 0x000000000061baa3 in main (argc=<optimized out>, argv=0x7f7fff3c0e48) at asterisk.c:3551
(gdb)
```

I was able to sufficiently identify the problem with this bug report:


https://community.asterisk.org/t/solved-illegal-instruction-error-after-ec2-instance-is-launched/76213

From this, it appears that Asterisk applies optimizations by default to the architecture on which it is built when creating binaries. Obviously, this causes these binaries to no longer run everywhere. In my case, the build system was a Xen VM running on a Xen host on an AMD FX-8350 system. The kernels in each case are NetBSD 9.1. The binary was then supposed to run on an Intel NUC5 with a Celeron processor, which failed.

The possibility of occurrence of this problem is known and described in Asterisk. Disabling native builds is mentioned as a possible solution:


https://wiki.asterisk.org/wiki/display/AST/Building+and+Installing+Asterisk#BuildingandInstallingAsterisk-Buildingfornon-nativearchitectures

Since we are very particular about platform independence in NetBSD and pkgsrc, would it make sense to disable the native optimizations for Asterisk by default? I don't know how many people use Asterisk from the official pkg binaries, but chances are that there are regular systems out there that don't run it in this form. Also for people who build their own pkg repository the current behavior might be an unpleasant surprise.

In options.mk I didn't find any prepared switches for this for now. I'll try to add one and get back to you with a patch if necessary. If this already exists, I would be glad about a short message.

Kind regards
Matthias


Home | Main Index | Thread Index | Old Index