clangen / musikcube

a cross-platform, terminal-based music player, audio engine, metadata indexer, and server in c++
https://musikcube.com
BSD 3-Clause "New" or "Revised" License
4.21k stars 295 forks source link

[Git master] musikcube segfaults during start-up in cursespp::App::InitCurses #588

Open hartwork opened 1 year ago

hartwork commented 1 year ago

This is with ncurses 6.4 and GCC 11.3.1.

Here's what I see in gdb:

# gdb -ex run -ex bt --batch --args ./bin/musikcube
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7ffff70a76c0 (LWP 18431)]
[New Thread 0x7fffec6b56c0 (LWP 18435)]
[New Thread 0x7fffebeb46c0 (LWP 18436)]
[New Thread 0x7fffeb6b36c0 (LWP 18437)]
[New Thread 0x7fffeaeb26c0 (LWP 18438)]
[Thread 0x7fffeb6b36c0 (LWP 18437) exited]
[New Thread 0x7fffea6b16c0 (LWP 18439)]
[Thread 0x7fffea6b16c0 (LWP 18439) exited]
[New Thread 0x7fffea6b16c0 (LWP 18440)]
[Thread 0x7fffea6b16c0 (LWP 18440) exited]
[New Thread 0x7fffea6b16c0 (LWP 18441)]
[Thread 0x7fffea6b16c0 (LWP 18441) exited]
[New Thread 0x7fffea6b16c0 (LWP 18442)]
[Thread 0x7fffea6b16c0 (LWP 18442) exited]
[New Thread 0x7fffea6b16c0 (LWP 18443)]
[Thread 0x7fffea6b16c0 (LWP 18443) exited]

Thread 1 "musikcube" received signal SIGSEGV, Segmentation fault.
0x00007ffff7b7f1ed in _nc_setupscreen_sp () from /lib64/libncursesw.so.6
#0  0x00007ffff7b7f1ed in _nc_setupscreen_sp () at /lib64/libncursesw.so.6
#1  0x00007ffff7b7a6ea in newterm_sp () at /lib64/libncursesw.so.6
#2  0x00007ffff7b7ab99 in newterm () at /lib64/libncursesw.so.6
#3  0x00007ffff7b76330 in initscr () at /lib64/libncursesw.so.6
#4  0x0000555555761049 in cursespp::App::InitCurses() (this=this@entry=0x7fffffffcf10) at /tmp/tmp.CUEQtW7yPK/musikcube/src/musikcube/cursespp/App.cpp:289
#5  0x0000555555761ea9 in cursespp::App::App(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (this=this@entry=0x7fffffffcf10, title="musikcube") at /tmp/tmp.CUEQtW7yPK/musikcube/src/musikcube/cursespp/App.cpp:280
#6  0x0000555555623938 in main(int, char**) (argc=<optimized out>, argv=<optimized out>) at /tmp/tmp.CUEQtW7yPK/musikcube/src/musikcube/Main.cpp:158

The build went as follows:

# cd "$(mktemp -d)"

# git clone --depth 1 https://github.com/clangen/musikcube
Cloning into 'musikcube'...
remote: Enumerating objects: 1778, done.
remote: Counting objects: 100% (1778/1778), done.
remote: Compressing objects: 100% (1514/1514), done.
remote: Total 1778 (delta 619), reused 778 (delta 221), pack-reused 0
Receiving objects: 100% (1778/1778), 5.14 MiB | 6.24 MiB/s, done.
Resolving deltas: 100% (619/619), done.

# cd musikcube/

# git rev-parse HEAD
b2652ad64348f1d416a9d243ac77f40cee7bc303

# git submodule update --init
Submodule 'src/3rdparty/asio' (https://github.com/chriskohlhoff/asio/) registered for path 'src/3rdparty/asio'
Submodule 'src/3rdparty/bin' (https://github.com/clangen/musikcube-bin) registered for path 'src/3rdparty/bin'
Cloning into '/tmp/tmp.CUEQtW7yPK/musikcube/src/3rdparty/asio'...
Cloning into '/tmp/tmp.CUEQtW7yPK/musikcube/src/3rdparty/bin'...
Submodule path 'src/3rdparty/asio': checked out '147f7225a96d45a2807a64e443177f621844e51c'
Submodule path 'src/3rdparty/bin': checked out '0f2c74ab939760bbad14cd1251aa89d64be6fe38'

# cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -S . -B build
-- The C compiler identification is GNU 11.3.1
-- The CXX compiler identification is GNU 11.3.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test HAVE_CXX_ATOMICS64_WITHOUT_LIB
-- Performing Test HAVE_CXX_ATOMICS64_WITHOUT_LIB - Success
-- Performing Test LLVM_HAS_ATOMICS
-- Performing Test LLVM_HAS_ATOMICS - Success
-- [standalone-build] *NOT* enabled!
-- [cross-compile] not enabled!
-- [vendor-link-directories] 
-- [vendor-include-directories] 
-- [os-system-libs] /usr/lib64/libdl.a
-- [build] musikcube_LINK_LIBS: /usr/lib64/libdl.a/usr/lib64/libcurl.so/usr/lib64/libssl.so/usr/lib64/libcrypto.so/usr/lib64/libz.so/usr/lib64/libpthread.a
-- [ncurses] using library names with 'w' prefix
-- [ncurses] not Darwin! will attempt to link against libtinfo
-- [musikcube] using libtinfo at: /usr/lib64/libtinfo.so
-- [musikcube] using libncurses at: /usr/lib64/libncursesw.so
-- [musikcube] using libpanel at: /usr/lib64/libpanelw.so
-- [taglibmetadatareader] using /usr/lib64/libtag.so
-- [add-vendor-includes] adding vendor includes to 'taglibreader'
-- [add-plugin] added taglibreader
-- [add-plugin] added alsaout
-- [add-plugin] skipped coreaudioout
-- [add-plugin] added nullout
-- Found PkgConfig: /usr/bin/pkg-config (found version "1.8.1") 
-- Checking for module 'libpipewire-0.3'
--   Found libpipewire-0.3, version 0.3.64
-- [add-plugin] added pipewireout
-- [portaudioout] using libportaudio at: /usr/lib64/libportaudio.so
-- [add-plugin] added portaudioout
-- [add-plugin] added pulseout
-- [add-plugin] skipped sndioout
-- [add-plugin] skipped macosmediakeys
-- Checking for module 'libsystemd'
--   Package 'libsystemd', required by 'virtual:world', not found
-- [add-plugin] skipped mpris
-- [server] using /usr/lib64/libmicrohttpd.so, /usr/lib64/libz.so
-- [add-plugin] added server
-- [add-vendor-includes] adding vendor includes to 'httpdatastream'
-- [add-plugin] added httpdatastream
-- [add-plugin] added ffmpegdecoder
-- [gmedecoder] using GME-NOTFOUND
-- [add-plugin] skipped gmedecoder
-- [add-plugin] skipped openmptdecoder
-- [add-plugin] added stockencoders
-- [add-plugin] added supereqdsp
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/tmp.CUEQtW7yPK/musikcube/build

# make -C build -j3
[..]

Any ideas?

clangen commented 1 year ago

I've had a couple reports of this behavior recently, and I think both times the user was using the kitty terminal emulator -- do you happen to be using kitty? If so, a quick way to work around the issue is to use TERM=xterm-256color musikcube when launching the app.

hartwork commented 1 year ago

Hi @clangen I retried with latest b4035271319588624fb4425b4b2e317f1ec723cd, same crash. I have Yakuake here, based on KDE's Konsole, ${TERM} is already set to xterm-256color.

Arniiiii commented 1 year ago

@hartwork show here what ldd-tree musikcube prints. it looks like situation in #610 .

hartwork commented 1 year ago

Hi @Gerodote interesting link, thanks! Compiling musikcube takes ages here, I can start a compile now and report back when it's finished… Could you help me understand why you closed #610 as completed? It seems like musikcube would still need a portable version of patch musikcube-3.0.1-tinfow.patch to work out of the box?

hartwork commented 1 year ago

@Gerodote PS: The build took about 30 minutes and is done now. Here's the output you asked for, annotations with !!! I did manually on top:

# lddtree bin/musikcube
bin/musikcube (interpreter => /lib64/ld-linux-x86-64.so.2)
    libcurl.so.4 => /usr/lib64/libcurl.so.4
        libcares.so.2 => /usr/lib64/libcares.so.2
        libnghttp2.so.14 => /usr/lib64/libnghttp2.so.14
    libssl.so.3 => /usr/lib64/libssl.so.3
    libcrypto.so.3 => /usr/lib64/libcrypto.so.3
    libz.so.1 => /lib64/libz.so.1
    libncursesw.so.6 => /lib64/libncursesw.so.6
        libtinfow.so.6 => /lib64/libtinfow.so.6                            !!!
    libpanelw.so.6 => /usr/lib64/libpanelw.so.6
    libtinfo.so.6 => /lib64/libtinfo.so.6                                  !!!
    libmusikcore.so => /tmp/tmp.Gv9RLzJCAc/musikcube/bin/libmusikcore.so
    libstdc++.so.6 => /usr/lib/gcc/x86_64-pc-linux-gnu/13/libstdc++.so.6
    libm.so.6 => /lib64/libm.so.6
    libgcc_s.so.1 => /usr/lib/gcc/x86_64-pc-linux-gnu/13/libgcc_s.so.1
    libc.so.6 => /lib64/libc.so.6

Related commit is d723f963607788e2ea495f878c2cac2b171ae0a2 .

Arniiiii commented 1 year ago

Hi @Gerodote interesting link, thanks! Compiling musikcube takes ages here, I can start a compile now and report back when it's finished… Could you help me understand why you closed #610 as completed? It seems like musikcube would still need a portable version of patch musikcube-3.0.1-tinfow.patch to work out of the box?

I thought it was gentoo related. I'll reopen it.

@Gerodote PS: The build took about 30 minutes and is done now. Here's the output you asked for, annotations with !!! I did manually on top:

# lddtree bin/musikcube
bin/musikcube (interpreter => /lib64/ld-linux-x86-64.so.2)
    libcurl.so.4 => /usr/lib64/libcurl.so.4
        libcares.so.2 => /usr/lib64/libcares.so.2
        libnghttp2.so.14 => /usr/lib64/libnghttp2.so.14
    libssl.so.3 => /usr/lib64/libssl.so.3
    libcrypto.so.3 => /usr/lib64/libcrypto.so.3
    libz.so.1 => /lib64/libz.so.1
    libncursesw.so.6 => /lib64/libncursesw.so.6
        libtinfow.so.6 => /lib64/libtinfow.so.6                            !!!
    libpanelw.so.6 => /usr/lib64/libpanelw.so.6
    libtinfo.so.6 => /lib64/libtinfo.so.6                                  !!!
    libmusikcore.so => /tmp/tmp.Gv9RLzJCAc/musikcube/bin/libmusikcore.so
    libstdc++.so.6 => /usr/lib/gcc/x86_64-pc-linux-gnu/13/libstdc++.so.6
    libm.so.6 => /lib64/libm.so.6
    libgcc_s.so.1 => /usr/lib/gcc/x86_64-pc-linux-gnu/13/libgcc_s.so.1
    libc.so.6 => /lib64/libc.so.6

Related commit is d723f96 .

maybe the patch that was mentioned in #610 can help you. or LD_PRELOAD= ... can help .

hartwork commented 1 year ago

I thought it was gentoo related. I'll reopen it.

@Gerodote interesting point. I'm running Gentoo, not sure how many other distros use tinfow and how many tinfo without w. Maybe you're right and it does need a fix in Gentoo or maybe it needs a fix in the other distros using it without w? :shrug:

I'll link https://bugs.gentoo.org/692954 back to here…

Arniiiii commented 1 year ago

I thought it was gentoo related. I'll reopen it.

@Gerodote interesting point. I'm running Gentoo, not sure how many other distros use tinfow and how many tinfo without w. Maybe you're right and it does need a fix in Gentoo :shrug:

I'll link https://bugs.gentoo.org/692954 back to here…

if you are on gentoo, you can install musikcube from guru overlay with mentioned patch