Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 725888 - net-misc/asterisk-* USE=-ssl causes build to hang
Summary: net-misc/asterisk-* USE=-ssl causes build to hang
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Jaco Kroon
URL: https://issues.asterisk.org/jira/brow...
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks: 716426
  Show dependency tree
 
Reported: 2020-05-28 15:20 UTC by Craig Metz
Modified: 2020-07-01 06:38 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Craig Metz 2020-05-28 15:20:38 UTC
USE="-ssl libressl" emerge asterisk

Gets this far in the build:

configure: Package configured for: 
configure: OS type  : linux-gnu
configure: Host CPU : x86_64
configure: build-cpu:vendor:os: x86_64 : pc : linux-gnu :
configure: host-cpu:vendor:os: x86_64 : pc : linux-gnu :
make NOISY_BUILD=yes menuselect.makeopts 
CC="cc" CXX="x86_64-pc-linux-gnu-g++" LD="" AR="" RANLIB="" CFLAGS="" LDFLAGS="" make -C menuselect CONFIGURE_SILENT="--silent" menuselect
make[1]: Entering directory '/var/tmp/portage/net-misc/asterisk-16.10.0/work/asterisk-16.10.0/menuselect'
gcc  -g -D_GNU_SOURCE -Wall -DHAVE_NCURSES -I/usr/include/libxml2   -c -o menuselect.o menuselect.c
gcc  -g -D_GNU_SOURCE -Wall -DHAVE_NCURSES   -c -o strcompat.o strcompat.c
gcc  -g -D_GNU_SOURCE -Wall -DHAVE_NCURSES   -c -o menuselect_stub.o menuselect_stub.c
gcc  -o menuselect menuselect.o strcompat.o menuselect_stub.o -lxml2 -lz -lm -ldl
make[1]: Leaving directory '/var/tmp/portage/net-misc/asterisk-16.10.0/work/asterisk-16.10.0/menuselect'
Generating input for menuselect ...
menuselect/menuselect --check-deps menuselect.makeopts

And then hangs until interrupted.
Same build environment without the libressl USE flag builds without this hang, including use of the ssl (but not libressl) USE flag.

Reproduced in multiple build environments including a clean install of stage3-amd64-20200527T214502Z.tar.xz
Comment 1 Craig Metz 2020-05-28 15:23:39 UTC
This is with the asterisk-16.10 package, which is ~amd64
Comment 2 Jonas Stein gentoo-dev 2020-05-28 16:08:33 UTC
Thank you for the report. We need to have all information at hand before ticket assignment. That is why I ask you to 
* attach the logs and 
* paste the emerge info 
as described on https://wiki.gentoo.org/wiki/Attach_the_logs_to_the_bug_ticket
Please reopen this ticket (Status:UNCONFIRMED) afterwards.
Comment 3 Jaco Kroon 2020-05-28 18:08:31 UTC
Hi Craig,

Someone else mentioned this on IRC as well, but didn't make the connection with libressl.

I don't use libressl myself.

Are you able to track the root cause?  My out of hand fix is to remove libressl USE flag, but obviously that's a bit knee-jerk.

Does 13.33.0 work for you?

Doesn't look like the menuselect source itself uses openssl/libressl so it has to be something on it's input.

Once it hangs, you could try attaching to it with strace and let me know if it's doing anything, and if so, grab me the strace output for a few hundred lines or so.

top will also let us know if it's in a busy loop perhaps, so if strace doesn't provide us any output, we want to know what leads up to it.

If need be I'll see if I can provide you a patch for making menuselect verbose as to what it's doing.
Comment 4 Jaco Kroon 2020-05-28 18:13:23 UTC
Just adding MENUSELECT_DEBUG=1 on line 147 of the ebuild may already help:

--- a/net-misc/asterisk/asterisk-16.10.0.ebuild
+++ b/net-misc/asterisk/asterisk-16.10.0.ebuild
@@ -144,7 +144,7 @@ src_configure() {
        sed -i 's/NATIVE_ARCH=/NATIVE_ARCH=0/' build_tools/menuselect-deps || die "Unable to squelc>
 
        # Compile menuselect binary for optional components
-       emake NOISY_BUILD=yes menuselect.makeopts
+       emake NOISY_BUILD=yes MENUSELECT_DEBUG=1 menuselect.makeopts
 
        # Disable BUILD_NATIVE (bug #667498)
        menuselect --disable build_native menuselect.makeopts

That will generate a menuselect_debug.txt file somewhere in the workdir.
Comment 5 Craig Metz 2020-05-28 22:33:25 UTC
Hi, Jaco,

Thank you for following up on this bug report. I did some more debugging, and I think I have identified several underlying bugs and fixes.

USE="-ssl libressl" emerge =net-misc/asterisk-13.33.0


Fails the same way:

configure: Package configured for:
configure: OS type  : linux-gnu
configure: Host CPU : x86_64
configure: build-cpu:vendor:os: x86_64 : pc : linux-gnu :
configure: host-cpu:vendor:os: x86_64 : pc : linux-gnu :
make -j4 NOISE_BUILD=yes menuselect.makeopts
CC="cc" CXX="x86_64-pc-linux-gnu-g++" LD="" AR="" RANLIB="" CFLAGS="" LDFLAGS="" make -C menuselect CONFIGURE_SILENT="--silent" menuselect
make[1]: Entering directory '/var/tmp/portage/net-misc/asterisk-13.33.0/work/asterisk-13.33.0/menuselect'
gcc  -g -D_GNU_SOURCE -Wall -DHAVE_NCURSES -I/usr/include/libxml2   -c -o menuselect.o menuselect.c
gcc  -g -D_GNU_SOURCE -Wall -DHAVE_NCURSES   -c -o strcompat.o strcompat.c
gcc  -g -D_GNU_SOURCE -Wall -DHAVE_NCURSES   -c -o menuselect_stub.o menuselect_stub.c   
gcc  -o menuselect menuselect.o strcompat.o menuselect_stub.o -lxml2 -lz -lm -ldl
make[1]: Leaving directory '/var/tmp/portage/net-misc/asterisk-13.33.0/work/asterisk-13.33.0/menuselect'
Generating input for menuselect ...
menuselect/menuselect --check-deps menuselect.makeopts
^C

So this affects both the stable and ~ versions.

I made the change you suggested (diff you posted) and tried again. No difference in output.

When I looked at the build working directory, there was no file menuselect.makeopts.

If I strace the hanging command, the output ends with:   

openat(AT_FDCWD, "build_tools/menuselect-deps", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=852, ...}) = 0
read(3, "ALSA=0\nBLUETOOTH=0\nBEANSTALK=0\nC"..., 4096) = 852
read(3, "", 4096)                       = 0
close(3)                                = 0
openat(AT_FDCWD, "menuselect.makeopts", O_RDONLY) = -1 ENOENT (No such file or directory)

^C--- SIGINT {si_signo=SIGINT, si_code=SI_KERNEL} ---

In contrast, if I emerge with USE="ssl -libressl" and interrupt the process at about the same point, I can see that it generated:

-rw-r--r--  1 portage portage   10301 May 28 18:28 menuselect.makeopts

and strace shows at about that point:

openat(AT_FDCWD, "build_tools/menuselect-deps", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=851, ...}) = 0
read(3, "ALSA=0\nBLUETOOTH=0\nBEANSTALK=0\nC"..., 4096) = 851
read(3, "", 4096)                       = 0
close(3)                                = 0
openat(AT_FDCWD, "menuselect.makeopts", O_RDONLY) = 3 
fstat(3, {st_mode=S_IFREG|0644, st_size=10301, ...}) = 0
read(3, "MENUSELECT_ADDONS=chan_mobile ch"..., 4096) = 4096
read(3, "ELECT_CEL=cel_tds\nMENUSELECT_DEP"..., 4096) = 4096
read(3, "D=MENUSELECT_TESTS=test_json\nMEN"..., 4096) = 2109
read(3, "", 4096)                       = 0
close(3)                                = 0
openat(AT_FDCWD, "menuselect.makeopts", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
write(3, "MENUSELECT_ADDONS=chan_mobile ch"..., 4096) = 4096
write(3, "ELECT_CEL=cel_tds\nMENUSELECT_DEP"..., 4096) = 4096
write(3, "D=MENUSELECT_TESTS=test_json\nMEN"..., 2109) = 2109
close(3)                                = 0
rt_sigaction(SIGINT, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f6aa3080fc0}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0

I then checked to see whether libressl was even installed. It was not. So I tried emerging libressl directly, which required me to first uninstall openssl. After doing this, building asterisk with USE=libressl did not hang / worked.

It appears that there are four possible bugs here:

1. libressl is not identified as a dependency when USE=libressl is set. I suspect that there are other packages in portage that also have this issue.

2. The make step that prints this output:

Generating input for menuselect ...

Fails when the libressl USE flag is set and libressl is not installed, failing to generate a menuselect.makeopts file

3. The makefiles/scripts fail to detect (2) and stop.

4. The menuselect program fails to handle the error opening the input file, and instead hangs.

(1) appears to be a possible Gentoo/portage bug.
(2)-(4) appear to be possible upstream Asterisk bugs.
Comment 6 Jaco Kroon 2020-05-29 08:21:16 UTC
Looking at the DEPEND flags:

 78     ssl? (
 79         !libressl? ( dev-libs/openssl:0= )
 80         libressl? ( dev-libs/libressl:0= )
 81     )

So to get libressl you need to stack the USE flags.

Without USE=ssl, USE=libressl *should* have no effect.  Perhaps a case for REQUIRED_USE to force ssl if libressl is set.

So three combinations of USE flags I'm interested in:

USE="-ssl -libressl"
USE="ssl -libressl"
USE="ssl libressl"

In both the latter two cases ./configure is passed --with-ssl, and --without-ssl in the first.  Please keep everything else exactly the same.
Comment 7 Jaco Kroon 2020-06-03 06:56:04 UTC
Looks like the culprit is USE=-ssl.

I'm trying to think of scenario's where USE=-ssl makes sense and I'm coming up empty ... is anyone going to object to forcing USE=ssl?
Comment 8 Jaco Kroon 2020-06-03 07:01:44 UTC
Just for my own sanity, sorry for the noise but I need to revert to other work:

[ebuild   R   ~] net-misc/asterisk-16.10.0::gentoo  USE="alsa bluetooth caps iconv mysql newt odbc pjproject snmp span srtp -calendar -cluster -curl -dahdi -debug -doc -freetds -gtalk -http -ilbc -ldap -libressl -lua -osplookup -oss -portaudio -postgres -radius (-selinux) -speex -ssl* -static -statsd -syslog -unbound -vorbis -xmpp" VOICEMAIL_STORAGE="odbc -file -imap" 0 KiB


checking for srtp2/srtp.h... (cached) yes
checking for srtp_get_version_string in -lsrtp2... yes
checking for srtp2/srtp.h... (cached) yes
configure: WARNING: ***
configure: WARNING: *** OpenSSL required when using libsrtp2, checking for libsrtp instead.
configure: WARNING: ***
checking for srtp_init in -lsrtp... yes
checking srtp/srtp.h usability... yes
checking srtp/srtp.h presence... yes
checking for srtp/srtp.h... yes

The conf message doesn't make sense for me.  Made me think that perhaps USE="-ssl -srtp" may build, but that fails too, so USE=-ssl is a reliable reproduction.  Above still hints that we may need to add REQUIRED_USE="srtp? ( ssl )" but I'll confirm later.
Comment 9 Craig Metz 2020-06-03 12:01:00 UTC
Hi, Jaco. I will get back to you with the tests you suggested.

There are valid use cases for wanting to build without SSL support.

Both libressl and srtp require ssl, so your proposed REQUIRED_USE() appears to be a good step.

If the libressl USE flag is specified, the libressl package needs to be brought in as a dependency.

Recall that what was failing was -ssl libressl, and that libressl wasn't even installed. These two items should fix the problem. What do you think?
Comment 10 Jaco Kroon 2020-06-03 12:21:49 UTC
Hi Craig,

I spoke with QA on IRC.  USE=libressl is a profile type flag specifying WHICH implementation of SSL should be pulled in.  So current behaviour with USE="-ssl libressl" not bringing in libressl is correct.  I was also advised AGAINST the addition of REQUIRED_USE="libressl? ( ssl )".

It looks like for srtp asterisk has the ability to handle it internally using openssl/libressl, *OR* libsrtp.  Thus the message above.  So I'm not so sure about the REQUIRED_USE any more.

I agree I'd prefer that USE="-ssl" be able to build.  I suspect this is an upstream bug though, but would need to troubleshoot more in depth, at least I'm able to reproduce at this stage.

For what it's worth, on a git checkout of asterisk at origin/13:

jkroon@plastiekpoot ~/projects/asterisk ((HEAD detached at origin/13)) $ ./configure --without-ssl
...
...
jkroon@plastiekpoot ~/projects/asterisk ((HEAD detached at origin/13)) $ make
CC="cc" CXX="g++" LD="" AR="" RANLIB="" CFLAGS="" LDFLAGS="" make -C menuselect CONFIGURE_SILENT="--silent" makeopts
make[1]: Entering directory '/home/jkroon/projects/asterisk/menuselect'
make[1]: 'makeopts' is up to date.
make[1]: Leaving directory '/home/jkroon/projects/asterisk/menuselect'
Generating input for menuselect ...
menuselect/menuselect --check-deps menuselect.makeopts
*hangs*

So I'll work from there, then it makes it simpler to push upstream too.

Also, I've opened:

https://issues.asterisk.org/jira/browse/ASTERISK-28930

Kind Regards,
Jaco
Comment 11 Craig Metz 2020-06-03 12:49:12 UTC
Hi, Jaco,

If that's the design, then we should be consistent with it.

I think you've isolated the bug. See possible issues 2-4 in my comment 5 for the cascade of code bugs. They are likely to be upstream bugs.

As a short-term response, can the portage file for asterisk error out with a message saying that the asterisk build is currently broken if -ssl and point to the isolated bug reports? I recall seeing such errors for other packages from time to time. While we shouldn't leave the bug unfixed, it would be helpful if we could get things to a point where the build from current portage at least won't hang forever with no error message.
Comment 12 Jaco Kroon 2020-06-26 05:46:00 UTC
https://issues.asterisk.org/jira/browse/ASTERISK-28930

Fixed upstream.  How desperate are you for a fix or can this wait for the next bump?  Happy to back-port the patch if urgent.
Comment 13 Craig Metz 2020-06-26 12:58:50 UTC
Hi, Jaco. Thank you for pursuing this.

We are able to work around this by ensuring that ssl is set, so can anyone else who hits this, and we have it documented here. That's not the right long-term solution, but it takes some of the pressure off. We started out with the build spinning forever, blocking an emerge process, and we didn't have any idea how to make it not do that, at least now we know what the user can change to get their system to a point where the emerge will complete.

How easy or painful do you think it would be to either back-port the patch (preferred) or to rig the ebuild to error out with a message if ssl is not set? The former would be a fix, while the latter is a better stop-gap.
Comment 14 Jaco Kroon 2020-06-30 12:29:58 UTC
I've pulled in the patch for all 13.* and 16.* ebuilds currently in the tree.  This should deal with this (as per my own testing).  Will just drop the patch again when 13.35.0 and 16.12.0 gets released.
Comment 15 Larry the Git Cow gentoo-dev 2020-07-01 06:38:45 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8f686a563d18dd50c5b15d11dd1d1da628dc3910

commit 8f686a563d18dd50c5b15d11dd1d1da628dc3910
Author:     Jaco Kroon <jaco@uls.co.za>
AuthorDate: 2020-06-30 11:36:24 +0000
Commit:     Joonas Niilola <juippis@gentoo.org>
CommitDate: 2020-07-01 06:38:33 +0000

    net-misc/asterisk: USE=-ssl fixes (16.11.1)
    
    Closes: https://bugs.gentoo.org/725888
    Signed-off-by: Jaco Kroon <jaco@uls.co.za>
    Closes: https://github.com/gentoo/gentoo/pull/16504
    Signed-off-by: Joonas Niilola <juippis@gentoo.org>

 net-misc/asterisk/asterisk-16.11.1.ebuild | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Additionally, it has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f9c28f1511efb4397b6b73f1a43dac9f7302b13a

commit f9c28f1511efb4397b6b73f1a43dac9f7302b13a
Author:     Jaco Kroon <jaco@uls.co.za>
AuthorDate: 2020-06-30 11:35:48 +0000
Commit:     Joonas Niilola <juippis@gentoo.org>
CommitDate: 2020-07-01 06:38:32 +0000

    net-misc/asterisk: USE=-ssl fixes (16.10.0)
    
    Bug: https://bugs.gentoo.org/725888
    Signed-off-by: Jaco Kroon <jaco@uls.co.za>
    Signed-off-by: Joonas Niilola <juippis@gentoo.org>

 net-misc/asterisk/asterisk-16.10.0.ebuild | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=153c4559d3633507f21afb300feab3d24bc76adb

commit 153c4559d3633507f21afb300feab3d24bc76adb
Author:     Jaco Kroon <jaco@uls.co.za>
AuthorDate: 2020-06-30 11:34:06 +0000
Commit:     Joonas Niilola <juippis@gentoo.org>
CommitDate: 2020-07-01 06:38:32 +0000

    net-misc/asterisk: USE=-ssl fixes (13.34.0)
    
    Bug: https://bugs.gentoo.org/725888
    Signed-off-by: Jaco Kroon <jaco@uls.co.za>
    Signed-off-by: Joonas Niilola <juippis@gentoo.org>

 net-misc/asterisk/asterisk-13.34.0.ebuild | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ff22a39875feb55d1920acdaa282f32e51d9f19e

commit ff22a39875feb55d1920acdaa282f32e51d9f19e
Author:     Jaco Kroon <jaco@uls.co.za>
AuthorDate: 2020-06-30 11:20:56 +0000
Commit:     Joonas Niilola <juippis@gentoo.org>
CommitDate: 2020-07-01 06:38:32 +0000

    net-misc/asterisk: USE=-ssl fixes (13.33.0)
    
    Bug: https://bugs.gentoo.org/725888
    Signed-off-by: Jaco Kroon <jaco@uls.co.za>
    Signed-off-by: Joonas Niilola <juippis@gentoo.org>

 net-misc/asterisk/asterisk-13.33.0.ebuild          |  3 +-
 .../asterisk/files/asterisk-13.33.0-nossl.patch    | 94 ++++++++++++++++++++++
 2 files changed, 96 insertions(+), 1 deletion(-)