Dudemanguy / vmn

Simplistic cli music player built on mpv and curses
GNU General Public License v3.0
36 stars 0 forks source link

segmentation fault (core dumped) #6

Open indeedwatson opened 4 years ago

indeedwatson commented 4 years ago

Not sure how to get a more detailed output than this.

Installed via AUR. Any more info you need let me know.

Dudemanguy commented 4 years ago

Huh, didn't know there was an AUR package for this. If you could get a backtrace for me with gdb, that would be nice. Arch strips debug symbols by default, so if you could rebuild the AUR package and edit it by adding this line options=(debug !strip), that would be helpful.

Then just run it in gdb, reproduce the segmentation fault, type "bt" to get the backtrace and post the output here. If you need any further help getting the backtrace, let me know.

indeedwatson commented 4 years ago

Thanks for responding:


# Maintainer: Vicente Reyes <vreyesvaldivieso@gmail.com>
pkgname=vmn-git
_pkgname=vmn
pkgver=r198.327b24c
pkgrel=1
license=("GPL3")
pkgdesc="Simplistic cli music player built on mpv and curses"
makedepends=("meson" "scdoc" "ninja")
depends=("ffmpeg" "mpv" "ncurses")
optdepends=()
arch=("x86_64")
url="https://github.com/Dudemanguy/vmn"
source=("${_pkgname}::git+https://github.com/Dudemanguy/vmn.git")
sha512sums=('SKIP')
options=(debug !strip)

pkgver() {
    cd "$_pkgname"
    printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
    cd "$_pkgname"
    meson \
        -Dwerror=false \
        --prefix /usr \
        "$srcdir/build"
    ninja -C "$srcdir/build"
}

package() {
    cd "$_pkgname"
    DESTDIR="$pkgdir" ninja -C "$srcdir/build" install
}

I edited the PKGBUILD to add the line you said, but when I proceed to install:

Appending CPPFLAGS from environment: '-D_FORTIFY_SOURCE=2'

meson.build:1:0: ERROR: Compiler clang can not compile programs.

A full log can be found at /home/yama/.cache/yay/vmn-git/src/build/meson-logs/meson-log.txt
==> ERROR: A failure occurred in build().
    Aborting...

log: https://paste.xinu.at/8GYdW/

Dudemanguy commented 4 years ago

Meh, some mysterious clang error that's probably not worth spending time on. Instead of using the PKGBUILD could you try a git clone and then compiling with the instructions on the README? Don't actually run the ninja -C build install line though. Instead the binary will be in ./build/vmn and it should have debug symbols. Run gdb with that one and see what you get in the backtrace.

indeedwatson commented 4 years ago
ninja: Entering directory `build'
[1/5] Compiling C object 'vmn@exe/src_command.c.o'.
FAILED: vmn@exe/src_command.c.o 
clang -Ivmn@exe -I. -I.. -Iinclude -I../include -Xclang -fcolor-diagnostics -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -g -fsanitize=signed-integer-overflow -fsanitize=undefined -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wshadow -Wno-unused-parameter -Wno-unused-variable -D_GNU_SOURCE -D_DEFAULT_SOURCE -MD -MQ 'vmn@exe/src_command.c.o' -MF 'vmn@exe/src_command.c.o.d' -o 'vmn@exe/src_command.c.o' -c ../src/command.c
../src/command.c:97:14: error: variable 'mpv_err' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
                } else if (strcmp(parse_arr[1], "set") == 0) {
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/command.c:103:7: note: uninitialized use occurs here
                if (mpv_err < 0) {
                    ^~~~~~~
../src/command.c:97:10: note: remove the 'if' if its condition is always true
                } else if (strcmp(parse_arr[1], "set") == 0) {
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/command.c:89:14: note: initialize the variable 'mpv_err' to silence this warning
                int mpv_err;
                           ^
                            = 0
1 error generated.
[2/5] Compiling C object 'vmn@exe/src_config.c.o'.
FAILED: vmn@exe/src_config.c.o 
clang -Ivmn@exe -I. -I.. -Iinclude -I../include -Xclang -fcolor-diagnostics -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -g -fsanitize=signed-integer-overflow -fsanitize=undefined -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wshadow -Wno-unused-parameter -Wno-unused-variable -D_GNU_SOURCE -D_DEFAULT_SOURCE -MD -MQ 'vmn@exe/src_config.c.o' -MF 'vmn@exe/src_config.c.o.d' -o 'vmn@exe/src_config.c.o' -c ../src/config.c
../src/config.c:229:7: error: logical not is only applied to the left hand side of this comparison [-Werror,-Wlogical-not-parentheses]
                if (!strcmp(token, "Ctrl") == 0) {
                    ^                      ~~
../src/config.c:229:7: note: add parentheses after the '!' to evaluate the comparison first
                if (!strcmp(token, "Ctrl") == 0) {
                    ^
                     (                         )
../src/config.c:229:7: note: add parentheses around left hand side expression to silence this warning
                if (!strcmp(token, "Ctrl") == 0) {
                    ^
                    (                     )
../src/config.c:361:13: error: declaration shadows a local variable [-Werror,-Wshadow]
                        for (int i = 0; i < cfg->tags_len; ++i) {
                                 ^
../src/config.c:348:8: note: previous declaration is here
                        int i = 0;
                            ^
2 errors generated.
[3/5] Compiling C object 'vmn@exe/src_library.c.o'.
FAILED: vmn@exe/src_library.c.o 
clang -Ivmn@exe -I. -I.. -Iinclude -I../include -Xclang -fcolor-diagnostics -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -g -fsanitize=signed-integer-overflow -fsanitize=undefined -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wshadow -Wno-unused-parameter -Wno-unused-variable -D_GNU_SOURCE -D_DEFAULT_SOURCE -MD -MQ 'vmn@exe/src_library.c.o' -MF 'vmn@exe/src_library.c.o.d' -o 'vmn@exe/src_library.c.o' -c ../src/library.c
../src/library.c:369:17: error: expression which evaluates to zero treated as a null pointer constant of type 'char *' [-Werror,-Wnon-literal-null-conversion]
        new[new_pos] = '\0';
                       ^~~~
../src/library.c:533:12: error: declaration shadows a local variable [-Werror,-Wshadow]
                for (int i = 0; i < len; ++i) {
                         ^
../src/library.c:510:11: note: previous declaration is here
        for (int i = 0; i < file_len; ++i) {
                 ^
2 errors generated.
[4/5] Compiling C object 'vmn@exe/src_main.c.o'.
FAILED: vmn@exe/src_main.c.o 
clang -Ivmn@exe -I. -I.. -Iinclude -I../include -Xclang -fcolor-diagnostics -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -g -fsanitize=signed-integer-overflow -fsanitize=undefined -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wshadow -Wno-unused-parameter -Wno-unused-variable -D_GNU_SOURCE -D_DEFAULT_SOURCE -MD -MQ 'vmn@exe/src_main.c.o' -MF 'vmn@exe/src_main.c.o.d' -o 'vmn@exe/src_main.c.o' -c ../src/main.c
../src/main.c:330:19: error: expression which evaluates to zero treated as a null pointer constant of type 'char *' [-Werror,-Wnon-literal-null-conversion]
        dir_info[0][i] = '\0';
                         ^~~~
../src/main.c:331:19: error: expression which evaluates to zero treated as a null pointer constant of type 'char *' [-Werror,-Wnon-literal-null-conversion]
        dir_info[1][i] = '\0';
                         ^~~~
../src/main.c:433:21: error: expression which evaluates to zero treated as a null pointer constant of type 'char *' [-Werror,-Wnon-literal-null-conversion]
        metadata[0][len] = '\0';
                           ^~~~
../src/main.c:434:21: error: expression which evaluates to zero treated as a null pointer constant of type 'char *' [-Werror,-Wnon-literal-null-conversion]
        metadata[1][len] = '\0';
                           ^~~~
../src/main.c:714:11: error: declaration shadows a local variable [-Werror,-Wshadow]
                                ITEM *cur = current_item(menu);
                                      ^
../src/main.c:500:8: note: previous declaration is here
        ITEM *cur;
              ^
../src/main.c:734:11: error: declaration shadows a local variable [-Werror,-Wshadow]
                                ITEM *cur = current_item(menu);
                                      ^
../src/main.c:500:8: note: previous declaration is here
        ITEM *cur;
              ^
../src/main.c:813:12: error: declaration shadows a local variable [-Werror,-Wshadow]
                for (int i = 0; i < strlen(cur); ++i) {
                         ^
../src/main.c:809:11: note: previous declaration is here
        for (int i = 0; i < lib->length; ++i) {
                 ^
7 errors generated.
ninja: build stopped: subcommand failed.
Dudemanguy commented 4 years ago

Geez, I didn't realize clang would get so upset here. I'll fix this up.

Dudemanguy commented 4 years ago

Alright it should compile now with a5c2d413. Thanks for testing so far.

indeedwatson commented 4 years ago

hmm i deleted the directory, cloned again, followed the steps and I'm getting the same error

Dudemanguy commented 4 years ago

Are you 100% sure you're on the latest commit? Check it with git log. It will still give you some warnings, but it should compile.

indeedwatson commented 4 years ago
commit a5c2d4134b0bbf5483a695524d1edc00893a0de3 (HEAD -> master, origin/master, ori
gin/HEAD)
Author: dudemanguy <random342@airmail.cc>
Date:   Tue Dec 10 08:14:15 2019 -0600

    fix some clang errors

    Clang still gives some warnings during compilation, but it's not nearly
    enough for me to think it's worth silencing them.

not sure what's happening

Dudemanguy commented 4 years ago

I just realized that the error log you got wasn't exactly the same as the errors I got when building with clang (why?). Hold on a second.

Dudemanguy commented 4 years ago

Okay could you try it now? I think 32cec5b should take care of everything in your error log.

indeedwatson commented 4 years ago

Not very familiar with gdb but is this what you asked for initially?

(gdb) run
Starting program: /home/yama/vmn/build/vmn 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
/usr/lib/../share/gcc-9.2.0/python/libstdcxx/v6/xmethods.py:731: SyntaxWarning: list indices must be integers or slices, not str; perhaps you missed a comma?
  refcounts = ['_M_refcount']['_M_pi']

Program received signal SIGSEGV, Segmentation fault.
                                                    0x00005555555c7750 in vmn_library_metadata (lib=0x7fffffffde58)
    at ../src/library.c:460
460             while ((tag = av_dict_get(fmt_ctx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
(gdb) bt
#0  0x00005555555c7750 in vmn_library_metadata (lib=0x7fffffffde58)
    at ../src/library.c:460
#1  0x00005555555cbddb in main (argc=1, argv=0x7fffffffe088) at ../src/main.c:82

PD. I got carried away following the steps and did the sudo install, how do I uninstall it now?

Dudemanguy commented 4 years ago

Thanks! That's what I was looking for indeed. Failing on that line is a bit worrisome. av_dict_get is an ffmpeg function that is supposed to read all the metadata of the particular file that's opened. Perhaps something went wrong with the avformat_open_input call earlier?

vmn recursively searches the library directory (default is ~/Music). I assume you have audio files somewhere in there and one (or more) of them is triggering that. You can specify a specific library directory with the --library argument. Do you mind confirming if it's just a small subset of files that causes the segfault by playing around with the --library argument?

PD. I got carried away following the steps and did the sudo install, how do I uninstall it now?

It's just ninja -C build uninstall.

Dudemanguy commented 4 years ago

P.S. I just realized I screwed up a variable earlier (causing a different segfault) so please pull the latest the latest changes again before testing.

indeedwatson commented 4 years ago
(gdb) run --library ~/Downloads
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/yama/vmn/build/vmn --library ~/Downloads
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
                                                    0x00005555555c7750 in vmn_library_metadata (lib=0x7fffffffde28)
    at ../src/library.c:460
460             while ((tag = av_dict_get(fmt_ctx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
(gdb) bt
#0  0x00005555555c7750 in vmn_library_metadata (lib=0x7fffffffde28)
    at ../src/library.c:460
#1  0x00005555555cbddb in main (argc=3, argv=0x7fffffffe058) at ../src/main.c:82

This how I'm supposed to do it?

Dudemanguy commented 4 years ago

Ah the syntax would actually be --library=~/Downloads (I should probably make argument parsing better). You don't have to run this part in gdb either. Basically, I think there's just a weird file somewhere in there that's causing the segfault. Hopefully you can pinpoint one of them down, upload it somewhere, and then I can test it and figure out a fix/workaround for the problem.

indeedwatson commented 4 years ago

Well it just hangs and nothing seems to happen when I do that. Ran in gdb just in case:

(gdb) run --library=~/Downloads
Starting program: /home/yama/vmn/build/vmn --library=~/Downloads
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
/usr/lib/../share/gcc-9.2.0/python/libstdcxx/v6/xmethods.py:731: SyntaxWarning: list indices must be integers or slices, not str; perhaps you missed a comma?
  refcounts = ['_M_refcount']['_M_pi']
Dudemanguy commented 4 years ago

If you have a very large library, it will take some time to initially parse every file for metadata and store it in cache. It should eventually print a message if you wait long enough.

indeedwatson commented 4 years ago

Okay I made a folder with one track and it loaded fast, is the interface supposed to look like this img-2019-12-10-23:45:22 img-2019-12-10-23:45:11

Dudemanguy commented 4 years ago

Yup, that's correct and the default view. That file has no metadata so it has calls it "Unknown artist" and so on. You can use --view=file-path if you want to use folder directories instead of file metadata for organizing. Also there's ways to change the tagging and sorting order and so on.

indeedwatson commented 4 years ago

hmm it's kind of unusual not to see the albums and tracks by default until you select an artist, but I'll use it some more and see how it feels. Guessing we can close this now?

Dudemanguy commented 4 years ago

hmm it's kind of unusual not to see the albums and tracks by default until you select an artist

Internally, everything is organized in a hierarchical manner that corresponds to ncurses menus. I could add an option that automatically opens/shows menus that are below the top item in the hierarchy (i.e. show the albums and tracks when scrolling through the artist menu). That's not a bad idea.

Guessing we can close this now?

Sure if the segfault actually fixed now. I didn't think it was since all I did was fix the clang build.

Dudemanguy commented 4 years ago

Guess it's all good now so closing this.

indeedwatson commented 4 years ago

Sorry I forgot to reply

Sure if the segfault actually fixed now. I didn't think it was since all I did was fix the clang build.

You were right earlier, it works when I launch it with a small library but not with the full library:

Starting program: /usr/local/bin/vmn 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
/usr/lib/../share/gcc-9.2.0/python/libstdcxx/v6/xmethods.py:731: SyntaxWarning: list indices must be integers or slices, not str; perhaps you missed a comma?
  refcounts = ['_M_refcount']['_M_pi']

Program received signal SIGSEGV, Segmentation fault.
                                                    0x00005555555c7750 in vmn_library_metadata (lib=0x7fffffffde68) at ../src/library.c:460
460             while ((tag = av_dict_get(fmt_ctx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
Dudemanguy commented 4 years ago

Could you figure out what specific file is causing the crash here? Maybe it's just a format I never use (I use flac and opus 99% of the time; mp3 on occasion), so I could have overlooked some quirk in parsing the metadata or something.

indeedwatson commented 4 years ago

Might take me a while but I'll try.