Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

asterisk 13.6.0 (new formula) #46126

Closed
wants to merge 1 commit into from
Closed

asterisk 13.6.0 (new formula) #46126

wants to merge 1 commit into from

Conversation

afh
Copy link
Contributor

@afh afh commented Nov 18, 2015

Toolkit for building communications applications

Please also consider merging #46125 since the PR contains this formula's optional dependency on spandsp.

@dunn
Copy link
Contributor

dunn commented Nov 19, 2015

We can ignore the first problem since it'll be dealt with in #46125 but looks like there'll need to be a depends_on "openssl":

==> audit problems
asterisk:
 * Can't find dependency "spandsp".
 * object files were linked against system openssl
These object files were linked against the deprecated system OpenSSL.
Adding `depends_on "openssl"` to the formula may help.
  /usr/local/Cellar/asterisk/13.6.0/lib/asterisk/modules/chan_iax2.so
  /usr/local/Cellar/asterisk/13.6.0/lib/asterisk/modules/func_aes.so
  /usr/local/Cellar/asterisk/13.6.0/lib/asterisk/modules/pbx_dundi.so
  /usr/local/Cellar/asterisk/13.6.0/lib/asterisk/modules/res_crypto.so
  /usr/local/Cellar/asterisk/13.6.0/lib/libasteriskssl.dylib
  /usr/local/Cellar/asterisk/13.6.0/sbin/asterisk

url "http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13.6.0.tar.gz"
sha256 "8a01b53c946d092ac561c11b404f68cd328306d0e3b434a7485a11d4b175005a"

option "with-sample-config", "Install the sample config files. NOTE. Without this, you won't have any config file."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any situation where you wouldn't want a sample config?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not yet so familiar with asterisk as to knowledgable answer that question.

As a base for this formula I used the last one that was removed in 29680ba, that is wehre with-sample-config option stems from.

I would be ok with removing it.

Toolkit for building communications applications
@afh
Copy link
Contributor Author

afh commented Nov 19, 2015

I came across a homebrew-asterisk tap by @leedm777, it might be worthwhile to base a common asterisk formula on those. I'll have a look.

What's everybody's opinion about this?

@afh
Copy link
Contributor Author

afh commented Nov 19, 2015

Interestingly the tapped asterisk segfaults for me. I'll dig deeper.

@leedm777 care to give any hints what may go wrong and how I might be able to help improve the tap or bring asterisk into the main homebrew repo?

@afh
Copy link
Contributor Author

afh commented Nov 19, 2015

The segfaults disappear when asterisk is compiled against the OpenSSL provided by the system, i.e. when depends "openssl" is from the formula.

@DomT4
Copy link
Member

DomT4 commented Nov 19, 2015

when depends "openssl" is from the formula.

Presuming it takes one, try feeding the configure script a path to our OpenSSL. Some scripts can get confused about which OpenSSL to use.

@afh
Copy link
Contributor Author

afh commented Nov 19, 2015

The previously mentioned homebrew-asterisk tap passes ``--with-ssl=Formula["openssl"].opt_prefix` to the configure script and asterisk also segfaults.

@DomT4
Copy link
Member

DomT4 commented Nov 19, 2015

If you can't get it working with our OpenSSL, we won't accept it here I'm afraid. You may need to check with upstream and see whether they are aware of any reason it wouldn't build against newer OpenSSL versions.

@afh
Copy link
Contributor Author

afh commented Nov 19, 2015

Interesting. What's the reason behind this requirement?

@MikeMcQuaid
Copy link
Member

The system version is deprecated, outdated and no longer really secure.

@DomT4
Copy link
Member

DomT4 commented Nov 19, 2015

OpenSSL 0.9.8, and by extension the system OpenSSL, is terrible. Outdated cipher choices & is dead upstream in ~5 weeks time.

@DomT4
Copy link
Member

DomT4 commented Nov 19, 2015

Garg, I jumped on Mike again 😓.

@MikeMcQuaid
Copy link
Member

@DomT4 Don't worry about it 😀

@afh
Copy link
Contributor Author

afh commented Nov 19, 2015

That makes sense.

@leedm777 any insight you could provide on why asterisk segfaults (for me?) when installed with homebrew's OpenSSL?

@adilinden
Copy link

I have been trying to build asterisk on El Capitan. Both the @leedm777 tap and the formula above result in 'Segmentation fault: 11' when I run asterisk after the build. It does build fine without errors.

@leedm777
Copy link
Contributor

Sorry for the wall of text, but there's a lot to respond to.

re: merging the formulas, I would be very happy with contributing the formulas in my tap back to Homebrew. I haven't because it started out as a personal project, and they were pretty specific to my day to day work with Asterisk. I've since made the formulas generic, and I'd say my tap is Pretty Good™. With the minor exception that it apparently it segfaults for some people. Yeah, except for that one thing.

If nothing else, I think there's a lot of good stuff in my tap that I would like to see in any official formula (making clang optional, an Asterisk-customized version of PJSIP (a.k.a. PJPROJECT), plist, dev-mode support, a Travis build catching devel and head failures early).

re: segfaults, with my tap I only see them when using --with-clang. Since clang support is new-ish, I haven't spent a lot of time trying to figure out what's going on. If you're seeing a segfault when using gcc (the default option), then there's something going on that I haven't been able to reproduce.

Any chance of getting a stack trace/core dump from when it happens? You may need to install --with-dev-mode so that the stack traces are actually useful instead of being optimized into oblivion.

And could you pastebin the output of brew ls --versions? There might be some dependency that Asterisk is picking up that would help me duplicate the problem.

re: OpenSSL support upstream, Asterisk should work with that latest OpenSSL. In fact, I'm really surprised it ran at all with 0.9.8.

re: sample configs, the Asterisk sample configs are not the best place to start; those are really more for reference documentation. Asterisk has recently started including better sample configs that target use cases instead of trying to be extensive documentation. The Makefile target installing them was added after 13.6.0, and I was planning on switching to installing the basic_pbx config once 13.7.0 was released.

If we're starting a formula based on 13.6.0, then I recommend backporting the the patch adding the Makefile target and installing basic-pbx as the default config.

@adilinden
Copy link

Any chance of getting a stack trace/core dump from when it happens? You may need to install --with-dev-mode so that the stack traces are actually useful instead of being optimized into oblivion.

How would I create stack traces? I can build on a clean VM and provide it later tonight.

@leedm777
Copy link
Contributor

How would I create stack traces?

There are some instructions on the Asterisk wiki. It recommends enabling BETTER_BACKTRACES, but that is not an option for OS X due to library support. Other than that, I think those instructions should work.

I just pushed an update to add a --without-optimizations option. You can use that instead of the --with-dev-mode option I mentioned above, just so that we're minimizing the differences between your fresh install and a plain brew install asterisk.

I can build on a clean VM and provide it later tonight.

Wow! Thanks for taking the time to work on it.

I should point out (since it's an easy step to miss on a fresh machine), that you will need to have the CLT installed for Asterisk to compile properly (see #34461). Be sure to run xcode-select --install before GCC is installed.

@adilinden
Copy link

Apologies, I promised too much. My saved VM is pre-Xcode. For some reason App Store is taking it's sweat time. 6 hours later and Xcode download has still 2 hours to go... Reading the Asterisk wiki for now.

@leedm777
Copy link
Contributor

@adilinden Yuck. Sorry for the hassle :-(

@adilinden
Copy link

I have to apologize again. I can no longer reproduce 'Segmentation fault: 11'. It builds fine and it starts fine. I do not know what to say...

I even tried a Core 2 Duo and a i5 hardware. In both cases, as well as my segfault issues, all Fusion VM running 10.11. Unfortunately I did not save the state of the segfault build. I rolled back to an earlier snapshot and reinstalled Xcode and homebrew.

@leedm777
Copy link
Contributor

@adilinden Thanks for taking the time to look into it. It's a crazy issue that is really hard to reproduce, unless it happens to you. When it happens, it happens every time you start Asterisk. Until it stops happening, then it's impossible to reproduce again.

On the bright side, at some point someone in the future may be googling for "segfault asterisk homebrew", come across this issue, and upload the backtrace or brew ls --versions that's needed to figure out what's going on.

To everyone else on the thread, is there enough interest that I should put up a PR proposing the Asterisk formulas from my tap? My biggest question would be if there are any concerns about having the keg-only version of PJSIP that's different from the standard formula.

@afh
Copy link
Contributor Author

afh commented Nov 21, 2015

After further investigation I came across the following oddity:
asterisk is linked to libssl and libcrypto in /usr/lib as well as to libasteriskssl.dylib in its Cellar,
but libasteriskssl.dylib itself is linked to libssl and libcrypto in $(brew --prefix).

Running asterisk compiled from the leedm777/homebrew-asterisk tap works fine if --disable-asteriskssl is passed to configure.

Could this be related to my uncommon homebrew installation location /opt/homebrew?

@leedm777 Could there be an issue with asterisk's configure and make setup?
As for your biggest question about PJSIP: How about making the asterisk optimised PJSIP a local resource for asterisk?

What do the homebrew maintainers think of the resource approach?


% otool -L $(brew --prefix)/sbin/asterisk
/opt/homebrew/sbin/asterisk:
    ❗️/opt/homebrew/Cellar/asteriskdev/13.6.0/lib/libasteriskssl.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1225.1.1)
    /usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.9.0)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
    /usr/lib/libicucore.A.dylib (compatibility version 1.0.0, current version 55.1.0)
    /usr/lib/libxslt.1.dylib (compatibility version 3.0.0, current version 3.26.0)
    /usr/lib/libsqlite3.dylib (compatibility version 9.0.0, current version 216.0.0)
    ❗️/usr/lib/libssl.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8)
    ❗️/usr/lib/libcrypto.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8)
    /opt/homebrew/opt/jansson/lib/libjansson.4.dylib (compatibility version 12.0.0, current version 12.0.0)
    /usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
    /usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libedit.3.dylib (compatibility version 2.0.0, current version 3.0.0)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 104.1.0)
% otool -L $(brew --prefix)/lib/libasteriskssl.dylib
/opt/homebrew/lib/libasteriskssl.dylib:
    /opt/homebrew/opt/asteriskdev/lib/libasteriskssl.dylib (compatibility version 0.0.0, current version 0.0.0)
    ❗️/opt/homebrew/opt/openssl/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
    ❗️/opt/homebrew/opt/openssl/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1225.1.1)

@DomT4
Copy link
Member

DomT4 commented Nov 21, 2015

Could this be related to my uncommon homebrew installation location /opt/homebrew?

Potentially. Some build scripts favour /usr/local and /usr over anything else. Can you manually tell asterisk where OpenSSL is via a configure variable?

@afh
Copy link
Contributor Author

afh commented Nov 21, 2015

@DomT4 Yes, that is possible via the --with-ssl option for configure and even though it is set to Formula['openssl'].opt_prefix the dylib oddity occurs.

@leedm777
Copy link
Contributor

@afh You're also picking up the system sqlite instead of homebrew's, which could also be a problem. And you're missing libgcc_s, libuuid and libncursesw, which is really strange.

I don't see the problem on my install, but I also have homebrew installed into /usr/local instead of /opt/homebrew. My guess is either Asterisk isn't searching the non-standard paths consistently, or it's searching them after /usr and /usr/local.

$ otool -L $(brew --prefix)/sbin/asterisk
/usr/local/sbin/asterisk:
    /usr/local/Cellar/asterisk/13.6.0/lib/libasteriskssl.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.9.0)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
    /usr/lib/libicucore.A.dylib (compatibility version 1.0.0, current version 55.1.0)
    /usr/lib/libxslt.1.dylib (compatibility version 3.0.0, current version 3.26.0)
    /usr/local/opt/sqlite/lib/libsqlite3.0.dylib (compatibility version 9.0.0, current version 9.6.0)
    /usr/local/opt/openssl/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/local/opt/jansson/lib/libjansson.4.dylib (compatibility version 12.0.0, current version 12.0.0)
    /usr/local/lib/libuuid.16.dylib (compatibility version 17.0.0, current version 17.22.0)
    /usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
    /usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libedit.3.dylib (compatibility version 2.0.0, current version 3.0.0)
    /usr/local/opt/ncurses/lib/libncursesw.6.dylib (compatibility version 6.0.0, current version 6.0.0)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 104.1.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1225.1.1)
    /usr/local/lib/gcc/5/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)

$ otool -L $(brew --prefix)/lib/libasteriskssl.dylib
/usr/local/lib/libasteriskssl.dylib:
    /usr/local/opt/asterisk/lib/libasteriskssl.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/local/opt/openssl/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1225.1.1)
    /usr/local/lib/gcc/5/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)

@MikeMcQuaid
Copy link
Member

@leedm777 We'd rather use the system versions of libraries where possible.

@afh
Copy link
Contributor Author

afh commented Nov 24, 2015

@leedm777 I've done further tests and used the formula from you tap, here are my findings:

After brew install asterisk --with-clang I see the following warning:

Warning: leedm777/asterisk/asterisk dependency gettext was built with a different C++ standard
library (libc++ from clang). This may cause problems at runtime.

Adding depends gettext did not get rid of that warning.

Asterisk was been built with libasteriskssl and the otool -L asterisk libasteriskssl shows:

/opt/homebrew/Cellar/asterisk/13.6.0/sbin/asterisk:
  /opt/homebrew/Cellar/asterisk/13.6.0/lib/libasteriskssl.dylib (compatibility version 0.0.0, current version 0.0.0)
  /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1225.1.1)
  /usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.9.0)
  /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
  /usr/lib/libicucore.A.dylib (compatibility version 1.0.0, current version 55.1.0)
  /usr/lib/libxslt.1.dylib (compatibility version 3.0.0, current version 3.26.0)
  /usr/lib/libsqlite3.dylib (compatibility version 9.0.0, current version 216.0.0)
  /usr/lib/libssl.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8)
  /usr/lib/libcrypto.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8)
  /opt/homebrew/opt/jansson/lib/libjansson.4.dylib (compatibility version 12.0.0, current version 12.0.0)
  /usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
  /usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)
  /usr/lib/libedit.3.dylib (compatibility version 2.0.0, current version 3.0.0)
  /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 104.1.0)
/opt/homebrew/Cellar/asterisk/13.6.0/lib/libasteriskssl.dylib:
  /opt/homebrew/opt/asterisk/lib/libasteriskssl.dylib (compatibility version 0.0.0, current version 0.0.0)
  /opt/homebrew/opt/openssl/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
  /opt/homebrew/opt/openssl/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
  /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1225.1.1)

With this setup asterisk crashes with a segfault, here's the LLDB backtrace:

(lldb) target create "/opt/homebrew/sbin/asterisk"
Current executable set to '/opt/homebrew/sbin/asterisk' (x86_64).
(lldb) command source -s 1 '/Volumes/Users/afh/./.lldbinit'
(lldb) run -Wc
Process 43342 launched: '/opt/homebrew/sbin/asterisk' (x86_64)
Asterisk 13.6.0, Copyright (C) 1999 - 2014, Digium, Inc. and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
[ Initializing Custom Configuration Options ]
Process 43342 stopped
* thread #1: tid = 0x1168dd5, 0x00007fff8906c8b0 libsystem_platform.dylib`_platform_strcmp + 176, queue = 'com.apple.main-
thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00007fff8906c8b0 libsystem_platform.dylib`_platform_strcmp + 176
libsystem_platform.dylib`_platform_strcmp:
->  0x7fff8906c8b0 <+176>: movdqa (%rdi,%rcx), %xmm0
    0x7fff8906c8b5 <+181>: movdqu (%rsi,%rcx), %xmm1
    0x7fff8906c8ba <+186>: pcmpeqb %xmm1, %xmm0
    0x7fff8906c8be <+190>: pcmpeqb %xmm2, %xmm1
(lldb) bt
* thread #1: tid = 0x1168dd5, 0x00007fff8906c8b0 libsystem_platform.dylib`_platform_strcmp + 176, queue = 'com.apple.main-
thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x00007fff8906c8b0 libsystem_platform.dylib`_platform_strcmp + 176
    frame #1: 0x00007fff864a247b libcrypto.0.9.8.dylib`lh_insert + 475
    frame #2: 0x00007fff8650f8f8 libcrypto.0.9.8.dylib`OBJ_NAME_add + 168
    frame #3: 0x00000001002e8c37 libssl.1.0.0.dylib`SSL_library_init + 71
    frame #4: 0x00000001002a789b libasteriskssl.dylib`ast_ssl_init + 149
    frame #5: 0x000000010001caf8 asterisk`main + 9590
    frame #6: 0x00000001000044c0 asterisk`start + 52

In the backtrace I stumbled upon frame #2, #3, #4. So I tried compiling asterisk with --disable-libasteriskssl:

/opt/homebrew/Cellar/asterisk/13.6.0/sbin/asterisk:
  /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1225.1.1)
  /usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.9.0)
  /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
  /usr/lib/libicucore.A.dylib (compatibility version 1.0.0, current version 55.1.0)
  /usr/lib/libxslt.1.dylib (compatibility version 3.0.0, current version 3.26.0)
  /usr/lib/libsqlite3.dylib (compatibility version 9.0.0, current version 216.0.0)
  /usr/lib/libssl.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8)
  /usr/lib/libcrypto.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8)
  /opt/homebrew/opt/jansson/lib/libjansson.4.dylib (compatibility version 12.0.0, current version 12.0.0)
  /usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
  /usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)
  /usr/lib/libedit.3.dylib (compatibility version 2.0.0, current version 3.0.0)
  /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 104.1.0)

For some odd reason even though the asterisk formula from your tap specifically uses the --with-ssl and --with-crypto flags for configure to pass the location of homebrew's OpenSSL the resulting binary links
to the system OpenSSL.

This compiled asterisk binary runs just fine.

Where would I look in asterisk's compile setup (configure et al) in order to find out/change which paths are checked in which order?

For me putting homebrew in /usr/local isn't an option for it collides with other software I have installed.

@leedm777
Copy link
Contributor

@afh That is an excellent detailed report. Thanks!

I think we're probably getting pretty far afield from this PR, so I've created leedm777/homebrew-asterisk#20 and suggest we move the discussion to there.

@leedm777
Copy link
Contributor

@MikeMcQuaid

We'd rather use the system versions of libraries where possible.

Interesting. I created leedm777/homebrew-asterisk#21 to track fixing that issue in my tap.

@afh
Copy link
Contributor Author

afh commented Nov 26, 2015

@leedm777 Thanks for tracking the issues on your tap. I need to sort out some of the confusion that I've had with trying to find a solution to the issue and will post updates to the aforementioned issues.

@tdsmith
Copy link
Contributor

tdsmith commented Apr 10, 2016

@afh Still interested in working on this?

@apjanke
Copy link
Contributor

apjanke commented May 3, 2016

Closing this due to inactivity/lack of response. If you'd still like to pursue this, feel free to respond to the previous comments/questions and re-open on the new homebrew/core repo.

@apjanke apjanke closed this May 3, 2016
@Homebrew Homebrew locked and limited conversation to collaborators Jul 10, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants