Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 785562 - net-wireless/wavemon-0.9.3 SIGSEGV on startup with sys-libs/ncurses-6.2-r1, in initscr / _nc_setupscreen_sp
Summary: net-wireless/wavemon-0.9.3 SIGSEGV on startup with sys-libs/ncurses-6.2-r1, i...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Alarig Le Lay
URL:
Whiteboard:
Keywords: PATCH, PullRequest
Depends on:
Blocks:
 
Reported: 2021-04-25 10:05 UTC by Cyp
Modified: 2023-01-07 09:08 UTC (History)
8 users (show)

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


Attachments
wavemon-0.9.3-avoid-raw-ncurses.patch (wavemon-0.9.3-avoid-raw-ncurses.patch,551 bytes, patch)
2021-05-03 17:48 UTC, Sergei Trofimovich (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Cyp 2021-04-25 10:05:10 UTC
Reemerging wavemon and ncurses doesn't help.

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7f5f6a0 in _nc_setupscreen_sp (spp=spp@entry=0x7fffffffcf98, slines=<optimized out>, scolumns=<optimized out>, output=output@entry=0x7ffff7d776c0 <_IO_2_1_stdout_>, filtered=<optimized out>, 
    slk_format=slk_format@entry=0) at /var/tmp/portage/sys-libs/ncurses-6.2-r1/work/ncurses-6.2/ncurses/base/lib_set_term.c:476
476     /var/tmp/portage/sys-libs/ncurses-6.2-r1/work/ncurses-6.2/ncurses/base/lib_set_term.c: No such file or directory.
(gdb) bt full
#0  0x00007ffff7f5f6a0 in _nc_setupscreen_sp (spp=spp@entry=0x7fffffffcf98, slines=<optimized out>, scolumns=<optimized out>, output=output@entry=0x7ffff7d776c0 <_IO_2_1_stdout_>, filtered=<optimized out>, 
    slk_format=slk_format@entry=0) at /var/tmp/portage/sys-libs/ncurses-6.2-r1/work/ncurses-6.2/ncurses/base/lib_set_term.c:476
        p = <optimized out>
        null_TTY = {c_iflag = 0, c_oflag = 0, c_cflag = 0, c_lflag = 0, c_line = 0 '\000', c_cc = '\000' <repeats 31 times>, c_ispeed = 0, c_ospeed = 0}
        env = <optimized out>
        bottom_stolen = 0
        sp = 0x555555576050
        support_cookies = false
#1  0x00007ffff7f5ae1c in newterm_sp (sp=<optimized out>, name=name@entry=0x555555576030 "xterm-256color", ofp=ofp@entry=0x7ffff7d776c0 <_IO_2_1_stdout_>, ifp=ifp@entry=0x7ffff7d769a0 <_IO_2_1_stdin_>)
    at /var/tmp/portage/sys-libs/ncurses-6.2-r1/work/ncurses-6.2/ncurses/base/lib_newterm.c:223
        slk_format = 0
        filter_mode = <optimized out>
        errret = 1
        result = 0x0
        current = 0x0
        its_term = 0x0
        _ofp = 0x7ffff7d776c0 <_IO_2_1_stdout_>
        _ifp = 0x7ffff7d769a0 <_IO_2_1_stdin_>
        new_term = 0x0
#2  0x00007ffff7f5b299 in newterm (name=name@entry=0x555555576030 "xterm-256color", ofp=0x7ffff7d776c0 <_IO_2_1_stdout_>, ifp=0x7ffff7d769a0 <_IO_2_1_stdin_>)
    at /var/tmp/portage/sys-libs/ncurses-6.2-r1/work/ncurses-6.2/ncurses/base/lib_newterm.c:356
        rc = <optimized out>
#3  0x00007ffff7f56bf0 in initscr () at /var/tmp/portage/sys-libs/ncurses-6.2-r1/work/ncurses-6.2/ncurses/base/lib_initscr.c:94
        env = <optimized out>
        name = 0x555555576030 "xterm-256color"
        result = <optimized out>
#4  0x000055555555898e in main (argc=<optimized out>, argv=<optimized out>) at wavemon.c:170
        bg_color = 0
        cur = <optimized out>
        next = <optimized out>
        blockmask = {__val = {249108103174, 9, 2, 0 <repeats 13 times>}}
        oldmask = {__val = {0 <repeats 16 times>}}


Reproducible: Always

Steps to Reproduce:
1. Run wavemon.
Actual Results:  
Crash in initscr().

Expected Results:  
No crash in initscr().

$ emerge --info
Portage 3.0.17 (python 3.8.8-final-0, default/linux/amd64/17.1/desktop/plasma, gcc-10.2.0, glibc-2.32-r7, 4.19.86-gentoo x86_64)
=================================================================
System uname: Linux-4.19.86-gentoo-x86_64-Intel-R-_Core-TM-_i7-3770K_CPU_@_3.50GHz-with-glibc2.2.5
KiB Mem:    32847692 total,    792728 free
KiB Swap:   33554428 total,  33550332 free
Timestamp of repository gentoo: Fri, 09 Apr 2021 08:00:01 +0000
Head commit of repository gentoo: ca04b60b26550f11f80fdef3dde58f53cbd8ab77
sh bash 5.0_p18
ld GNU ld (Gentoo 2.35.1 p2) 2.35.1
ccache version 4.2 [disabled]
app-shells/bash:          5.0_p18::gentoo
dev-java/java-config:     2.3.1::gentoo
dev-lang/perl:            5.30.3::gentoo
dev-lang/python:          2.7.18_p7::gentoo, 3.8.8::gentoo, 3.9.2::gentoo
dev-lang/rust:            1.47.0-r2::gentoo
dev-util/ccache:          4.2::gentoo
dev-util/cmake:           3.20.1::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.7::gentoo
sys-apps/openrc:          0.42.1-r1::gentoo
sys-apps/sandbox:         2.20::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r5::gentoo
sys-devel/automake:       1.13.4-r2::gentoo, 1.15.1-r2::gentoo, 1.16.2-r1::gentoo
sys-devel/binutils:       2.35.1-r1::gentoo
sys-devel/gcc:            6.5.0-r3::gentoo, 7.5.0-r1::gentoo, 8.4.0-r2::gentoo, 9.3.0-r2::gentoo, 10.2.0-r5::gentoo
sys-devel/gcc-config:     2.3.3::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.3::gentoo
sys-kernel/linux-headers: 5.10::gentoo (virtual/os-headers)
sys-libs/glibc:           2.32-r7::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-verify-metamanifest: yes
    sync-rsync-extra-opts: 
    sync-rsync-verify-max-age: 24
    sync-rsync-verify-jobs: 1

My_local_repo
    location: /usr/local/portage
    masters: gentoo
    priority: 0

dotnet
    location: /var/lib/layman/dotnet
    masters: gentoo
    priority: 50

mrueg
    location: /var/lib/layman/mrueg
    masters: gentoo
    priority: 50

sage-on-gentoo
    location: /var/lib/layman/sage-on-gentoo
    masters: gentoo
    priority: 50

ssnb
    location: /var/lib/layman/ssnb
    masters: gentoo
    priority: 50

torbrowser
    location: /var/lib/layman/torbrowser
    masters: gentoo
    priority: 50

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe -g"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib/X11/xkb /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php7.4/ext-active/ /etc/php/cgi-php7.4/ext-active/ /etc/php/cli-php7.4/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=native -O2 -pipe -g"
DISTDIR="/usr/portage/distfiles"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS=" http://ftp.snt.utwente.nl/pub/os/linux/gentoo http://mirror.leaseweb.com/gentoo/ http://mirrors.evowise.com/gentoo/ http://mirror.mdfnet.se/gentoo "
LANG="en_US.UTF8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-O1"
LINGUAS="en da it pt pt_BR"
MAKEOPTS="-j8"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="3dnow 3dnowext X a52 aac aalib acl acpi activities alisp alsa amd64 apache2 apng ares bash-completion bazaar bdf berkdb bluetooth branding bzip2 cairo cdda cdr cli crypt css cups curl cvs d dbus dec_av2 declarative dhcp djvu dk doc dri dts dvd dvdr dvipdfm ebook editor elogind emboss emoticons-manager encode epub exif expat extensions extra ffmpeg firefox3 flac fluidsynth fontconfig foomaticdb fortran g3dvl gcj gd gdbm geoip gif git gles gles1 gles2 glitz gmp go gpm graphite graphviz gtk gui iconv icu imlib ipv6 irda ithreads jadetex java jpeg jpeg2k kde kerberos kipi kompare kpathsea kwallet lcms libcaca libglvnd libnotify libtirpc live llvm logitech-mouse lto lzma mad mercurial midi mikmod mjpeg mmxext mng mobi mod mozilla mp2 mp3 mp4 mpeg msn mudflap multilib multitarget mysql ncurses net45 network nls nodrm nptl nsplugin objc objc++ objc-gc offensive ogg ogre ois opengl openmp otr pam pango pcre pdf phonon plasma plotutils png policykit povray ppds qml qt5 qthelp readline rle rtmp samba scanner sdl se_swedb seccomp semantic-desktop server sift sip sndfile solver speex spell split-usr sql ssl ssse3 startup-notification subversion svg tcpd tga theora threads tiff timidity tk tokenizer truetype udev udisks unicode upower usb v4l v4l2 vcd video videos vnc vorbis vpx wav wayland webkit widgets wma wxwidgets x264 x265 xattr xcb xcomposite xine xml xscreensaver xv xvid xvmc zip zlib zstd" ABI_X86="64" ADA_TARGET="gnat_2018" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="*" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev libinput" KERNEL="linux" L10N="da en it pt pt-BR" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-3 php7-4" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_8" PYTHON_TARGETS="python3_8" RUBY_TARGETS="ruby26" USERLAND="GNU" VIDEO_CARDS="v4l vesa vga intel radeon r600" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RUSTFLAGS
Comment 1 Sergei Trofimovich (RETIRED) gentoo-dev 2021-04-25 10:14:01 UTC
I wonder if it's another case of mixing ncurses and ncursesw libraries in the same binary (like bug #669096). Can you post `lddrtee` output on crashing binary?
Comment 2 Sergei Trofimovich (RETIRED) gentoo-dev 2021-04-25 10:17:04 UTC
For example for me both `tinfo` and tinfow` are pulled in. That is likely a problem:

```
$ lddtree /usr/bin/wavemon
/usr/bin/wavemon (interpreter => /lib64/ld-linux-x86-64.so.2)
    libcap.so.2 => /lib64/libcap.so.2
    libncursesw.so.6 => /lib64/libncursesw.so.6
        libdl.so.2 => /lib64/libdl.so.2
        libtinfow.so.6 => /lib64/libtinfow.so.6
    libm.so.6 => /lib64/libm.so.6
    libtinfo.so.6 => /lib64/libtinfo.so.6
    libnl-genl-3.so.200 => /usr/lib64/libnl-genl-3.so.200
    libnl-3.so.200 => /usr/lib64/libnl-3.so.200
    libpthread.so.0 => /lib64/libpthread.so.0
    libc.so.6 => /lib64/libc.so.6
```
Comment 3 Sergei Trofimovich (RETIRED) gentoo-dev 2021-04-25 10:21:15 UTC
I think mix comes from:

```
PKG_CHECK_MODULES(ncurses,ncurses,LIBS="$LIBS $ncurses_LIBS",)
...
AC_CHECK_LIB([ncursesw], [waddstr],...
```

in configure.ac.
Comment 4 Cyp 2021-04-25 10:22:26 UTC
$ lddtree $(which wavemon)
wavemon => /usr/bin/wavemon (interpreter => /lib64/ld-linux-x86-64.so.2)
    libncursesw.so.6 => /lib64/libncursesw.so.6
        libdl.so.2 => /lib64/libdl.so.2
            ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2
        libtinfow.so.6 => /lib64/libtinfow.so.6
    libm.so.6 => /lib64/libm.so.6
    libtinfo.so.6 => /lib64/libtinfo.so.6
    libnl-genl-3.so.200 => /usr/lib64/libnl-genl-3.so.200
    libnl-3.so.200 => /usr/lib64/libnl-3.so.200
    libpthread.so.0 => /lib64/libpthread.so.0
    libc.so.6 => /lib64/libc.so.6

---- [below written before seeing above comment]

Same crash (apart from line numbers) after updating to sys-libs/ncurses-6.2_p20210123.

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7f5f790 in _nc_setupscreen_sp (spp=spp@entry=0x7fffffffd228, slines=<optimized out>, scolumns=<optimized out>, output=output@entry=0x7ffff7d766c0 <_IO_2_1_stdout_>, filtered=<optimized out>, 
    slk_format=slk_format@entry=0) at /var/tmp/portage/sys-libs/ncurses-6.2_p20210123/work/ncurses-6.2/ncurses/base/lib_set_term.c:501
warning: Source file is more recent than executable.
501             if (sp->_default_fg >= MaxColors) {
(gdb) bt full
#0  0x00007ffff7f5f790 in _nc_setupscreen_sp (spp=spp@entry=0x7fffffffd228, slines=<optimized out>, scolumns=<optimized out>, output=output@entry=0x7ffff7d766c0 <_IO_2_1_stdout_>, filtered=<optimized out>, 
    slk_format=slk_format@entry=0) at /var/tmp/portage/sys-libs/ncurses-6.2_p20210123/work/ncurses-6.2/ncurses/base/lib_set_term.c:501
        p = <optimized out>
        null_TTY = {c_iflag = 0, c_oflag = 0, c_cflag = 0, c_lflag = 0, c_line = 0 '\000', c_cc = '\000' <repeats 31 times>, c_ispeed = 0, c_ospeed = 0}
        env = <optimized out>
        bottom_stolen = 0
        sp = 0x555555576050
        support_cookies = false
#1  0x00007ffff7f5aefc in newterm_sp (sp=<optimized out>, name=name@entry=0x555555576030 "xterm-256color", ofp=ofp@entry=0x7ffff7d766c0 <_IO_2_1_stdout_>, ifp=ifp@entry=0x7ffff7d759a0 <_IO_2_1_stdin_>)
    at /var/tmp/portage/sys-libs/ncurses-6.2_p20210123/work/ncurses-6.2/ncurses/base/lib_newterm.c:234
        slk_format = 0
        filter_mode = <optimized out>
        errret = 1
        result = 0x0
        current = 0x0
        its_term = 0x0
        _ofp = 0x7ffff7d766c0 <_IO_2_1_stdout_>
        _ifp = 0x7ffff7d759a0 <_IO_2_1_stdin_>
        new_term = 0x0
#2  0x00007ffff7f5b379 in newterm (name=name@entry=0x555555576030 "xterm-256color", ofp=0x7ffff7d766c0 <_IO_2_1_stdout_>, ifp=0x7ffff7d759a0 <_IO_2_1_stdin_>)
    at /var/tmp/portage/sys-libs/ncurses-6.2_p20210123/work/ncurses-6.2/ncurses/base/lib_newterm.c:367
        rc = <optimized out>
#3  0x00007ffff7f56d40 in initscr () at /var/tmp/portage/sys-libs/ncurses-6.2_p20210123/work/ncurses-6.2/ncurses/base/lib_initscr.c:93
        env = <optimized out>
        name = 0x555555576030 "xterm-256color"
        result = <optimized out>
#4  0x000055555555898e in main (argc=<optimized out>, argv=<optimized out>) at wavemon.c:170
        bg_color = 0
        cur = <optimized out>
        next = <optimized out>
        blockmask = {__val = {2, 0 <repeats 15 times>}}
        oldmask = {__val = {0 <repeats 16 times>}}
Comment 5 Alarig Le Lay 2021-04-26 07:38:05 UTC
Isn’t it an issue with ncurses rather than wavemon?
Comment 6 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2021-04-26 07:43:26 UTC
(In reply to Alarig Le Lay from comment #5)
> Isn’t it an issue with ncurses rather than wavemon?

No.  #c1 says what the problem is, and #c3 points to the exact broken code.
Comment 7 Toni Ballesta 2021-05-03 16:25:23 UTC
Same situation for me. Same bug on previous ebuild 0.9.2 and this 0.9.3. Works correctly with 0.8.0 and 0.9.1 (local version) for test (used 0.9.1 actually on Debian testing/unstable actually, probably due by the commented on #1 and #6).

I think previous versions of wavemon like 0.8.0 and 0.9.1 (this not ported on portage) will be present on the tree, unmasked and masking the 0.9.3.
Comment 8 Sergei Trofimovich (RETIRED) gentoo-dev 2021-05-03 17:48:53 UTC
Created attachment 705777 [details, diff]
wavemon-0.9.3-avoid-raw-ncurses.patch

To avoid library mix you can just drop ncursesw part of it: wavemon-0.9.3-avoid-raw-ncurses.patch
Comment 9 mehw 2021-05-10 07:33:38 UTC
Hopefully https://github.com/gentoo/gentoo/pull/20749 solves the segmentation fault by either linking libncursesw along with libtinfow, or libncurses with libtinfo.

It changes files/wavemon-0.9.3-build.patch into allowing configure.ac to set the ncurses(w) LIBS via PKG_CHECK_MODULES:

AC_CHECK_LIB([ncursesw]... PKG_CHECK_MODULES([ncursesw]... [LIBS="$LIBS $ncursesw_LIBS"]...
    AC_CHECK_LIB([ncurses]... PKG_CHECK_MODULES([ncurses]... [LIBS="$LIBS $ncurses_LIBS"]...)
Comment 10 Larry the Git Cow gentoo-dev 2021-06-03 07:01:23 UTC
The bug has been closed via the following commit(s):

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

commit cd2fe787cf93eaa7e82564b901993447273e8367
Author:     Matthew White <mehw.is.me@inventati.org>
AuthorDate: 2021-05-10 00:05:49 +0000
Commit:     Joonas Niilola <juippis@gentoo.org>
CommitDate: 2021-06-03 07:01:11 +0000

    net-wireless/wavemon-0.9.3: fix ncurses(w) libs
    
    Fixes a segmentation fault due to linking with libncursesw and
    libtinfo, rather than libtinfow.
    
    See also https://github.com/uoaerg/wavemon/issues/88 about the
    segmentation fault error.
    
    If libncursesw is available uses ncursesw_LIBS, otherwise uses
    ncurses_LIBS if libncurses remains the only option.
    
    Closes: https://bugs.gentoo.org/785562
    Signed-off-by: Matteo Bianco <mehw.is.me@inventati.org>
    Closes: https://github.com/gentoo/gentoo/pull/20749
    Signed-off-by: Joonas Niilola <juippis@gentoo.org>

 net-wireless/wavemon/files/wavemon-0.9.3-build.patch | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)