j0ru / kickoff

Minimalistic program launcher
GNU General Public License v3.0
386 stars 11 forks source link

"Couldn't find font" - crash #22

Open daneov opened 2 years ago

daneov commented 2 years ago

When running kickoff I receive the following stacktrace:

Daneo-XPS% RUST_BACKTRACE=full kickoff
thread 'tokio-runtime-worker' panicked at 'Couldn't find font', /home/daneo/.cargo/registry/src/github.com-1ecc6299db9ec823/kickoff-0.5.0/src/font.rs:22:45
stack backtrace:
   0:     0x560c05e79435 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h18674753585b8cc5
   1:     0x560c05cb53bc - core::fmt::write::h650970577346edc1
   2:     0x560c05e77ef4 - std::io::Write::write_fmt::hcdbe4458fe2ebdfb
   3:     0x560c05e785eb - std::panicking::default_hook::{{closure}}::h2b3ca2e1a25274db
   4:     0x560c05e7799a - std::panicking::rust_panic_with_hook::habc6079310c0728a
   5:     0x560c05e987e8 - std::panicking::begin_panic_handler::{{closure}}::ha449aee990d62948
   6:     0x560c05e98766 - std::sys_common::backtrace::__rust_end_short_backtrace::h54cc540f2a5a6bf2
   7:     0x560c05e98722 - rust_begin_unwind
   8:     0x560c05c73930 - core::panicking::panic_fmt::he85288327cd30385
   9:     0x560c05cb6120 - core::panicking::panic_display::h78973eb85f3c7fcb
  10:     0x560c05c73b8b - core::option::expect_failed::h8b4000216a5a1a81
  11:     0x560c05cfe8ec - kickoff::font::Font::new::h0d46d20d8c63056a
  12:     0x560c05d27c2c - tokio::runtime::task::harness::poll_future::heb5b6ecccf7dde17
  13:     0x560c05c92464 - tokio::runtime::task::raw::poll::hf3706922d73ca782
  14:     0x560c05ebabde - tokio::runtime::thread_pool::worker::Context::run_task::h904c87cce3ecce93
  15:     0x560c05ea7a80 - tokio::runtime::task::raw::poll::h941af331f075f74b
  16:     0x560c05eb4a45 - tokio::runtime::blocking::pool::Inner::run::h55390d55cd0c82dc
  17:     0x560c05eacb0e - std::sys_common::backtrace::__rust_begin_short_backtrace::h42b1c0ea489b853e
  18:     0x560c05ebc02d - core::ops::function::FnOnce::call_once{{vtable.shim}}::h11780ba8122bdbd3
  19:     0x560c05ea1af5 - std::sys::unix::thread::Thread::new::thread_start::h2582dd3e3de2d3c5
  20:     0x7f2d6bd83eae - start_thread
                               at /builddir/glibc-2.32/nptl/pthread_create.c:463:8
  21:     0x7f2d6bb6c2ff - __GI___clone
                               at /builddir/glibc-2.32/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95
  22:                0x0 - <unknown>
Error: JoinError::Panic(...)

My config file:

Daneo-XPS% cat .config/kickoff/config.toml
# Kickoff default config

# Characters shown in front of the query.
prompt = ''

# space between window border and the content in pixel
padding = 100

fonts = ['Liberation Mono']        # otf or ttf only
font_size = 32.0

[history]
decrease_interval = 48 # interval to decrease the number of launches

[colors]
# color format: rgb or rgba, if transparency is desired
background = '#282c34aa'
prompt = '#abb2bfff'
text = '#ffffffff'          # for search results
text_query = '#e5c07bff'    # for the search query
text_selected = '#61afefff' # for the currently selected result

[keybindings]
# keybindings syntax: ctrl/shift/alt/logo as modifiers and a key joined by '+' signs
# A list of available keys can be found here: https://docs.rs/crate/x11-keysymdef/0.2.0/source/src/keysym.json
paste = ["ctrl+v"]
execute = ["KP_Enter", "Return"]
delete = ["KP_Delete", "Delete", "BackSpace"]
delete_word = ["ctrl+KP_Delete", "ctrl+Delete", "ctrl+BackSpace"]
complete = ["Tab"]
nav_up = ["Up"]
nav_down = ["Down"]
exit = ["Escape"]

Confirmation that the font is installed:

Daneo-XPS% fc-list -v | grep -B10 ttf | grep fullname
    fullname: "Liberation Mono"(s)
    fullnamelang: "en"(s)
    fullname: "Liberation Serif Bold Italic"(s)
    fullnamelang: "en"(s)
    fullname: "Liberation Sans Italic"(s)
    fullnamelang: "en"(s)
    fullname: "Liberation Sans"(s)
    fullnamelang: "en"(s)
    fullname: "Liberation Mono Italic"(s)
    fullnamelang: "en"(s)
    fullname: "Liberation Mono Bold Italic"(s)
    fullnamelang: "en"(s)
    fullname: "Liberation Serif Italic"(s)
    fullnamelang: "en"(s)
    fullname: "Liberation Sans Bold"(s)
    fullnamelang: "en"(s)
    fullname: "Liberation Serif Bold"(s)
    fullnamelang: "en"(s)
    fullname: "Liberation Sans Bold Italic"(s)
    fullnamelang: "en"(s)
    fullname: "Liberation Serif"(s)
    fullnamelang: "en"(s)
    fullname: "Twitter Color Emoji SVGinOT"(s)
    fullnamelang: "en"(s)
    fullname: "Liberation Mono Bold"(s)
    fullnamelang: "en"(s)

Any ideas? Or things I can help to determine where this goes wrong?

Thanks!

j0ru commented 2 years ago

What Version are you using? I recently changed some things regarding font rendering.

daneov commented 2 years ago

The latest available at the time this issue was created, installed via cargo install kickoff. Running kickoff with --version or version doesn't give any response, immediate crash.

j0ru commented 2 years ago

Okay, that's using the latest font loading code :/ Could you build a debug version from the latest main and post the output of RUST_BACKTRACE=full cargo run

daneov commented 2 years ago

Sure. I just tried to execute cargo build, but it returns:

  = note: /bin/ld: cannot find -lxkbcommon
          collect2: error: ld returned 1 exit status
error: could not compile `kickoff` due to previous error
Even though I have it installed (click to expand) ``` > Daneo-XPS% sudo xbps-query libxkbcommon architecture: x86_64 automatic-install: yes filename-sha256: 1a2def214305c54e26e99f4c49722cdd50058469c2aa4b98b708b0191cf4bcf5 filename-size: 135KB homepage: https://xkbcommon.org/ install-date: 2022-03-07 21:27 CET installed_size: 292KB license: MIT maintainer: Isaac Freund metafile-sha256: 772522711148c51affb13eb6bf7c10cb0d43747d137f54fea4e87cbac48bb45a pkgname: libxkbcommon pkgver: libxkbcommon-1.3.1_1 repository: https://alpha.de.repo.voidlinux.org/current run_depends: xkeyboard-config>=0 glibc>=2.32_1 shlib-provides: libxkbcommon.so.0 shlib-requires: libc.so.6 short_desc: Library to handle keyboard descriptions source-revisions: libxkbcommon:8da18c61c3 state: installed ```

Do you have any tips on how to proceed?

j0ru commented 2 years ago

Unfortunately I have no experience with void linux and at the moment not the time to learn it. It is weird that the compile fails with missing xkbcommon, that dependencies has been present from the beginning of this project and previous compiles have worked on your system. Maybe that's something to look at.

I'm open for PR's but I don't intend to build void support myself for now.

cplir-c commented 2 months ago

Oh hey! I had exactly the same issue compiling on Void Linux. I'm looking into it My xbps-query says:

architecture: x86_64-musl
automatic-install: yes
changelog: https://github.com/xkbcommon/libxkbcommon/blob/master/NEWS.md
filename-sha256: 0293b68dc044e4214bc105ce450795055bd91cec2f30111e79df393d0a717588
filename-size: 141KB
homepage: https://xkbcommon.org/
install-date: 2024-04-01 12:39 CDT
installed_size: 304KB
license: MIT
maintainer: Andrew J. Hesford <ajh@sideband.org>
metafile-sha256: 09e5c22c800c0642220286088a74ced69652cac581d1cef5e7ba27f193172e1a
pkgname: libxkbcommon
pkgver: libxkbcommon-1.7.0_1
repository: https://repo-default.voidlinux.org/current/musl
run_depends:
    xkeyboard-config>=0
    musl>=1.1.24_7
shlib-provides:
    libxkbcommon.so.0
shlib-requires:
    libc.so
short_desc: Library to handle keyboard descriptions
source-revisions: libxkbcommon:9defcef69d9
state: installed
cplir-c commented 2 months ago

I ran ld -lxkbcommon --verbose as suggested by this stackoverflow comment and got:

...
attempt to open /usr/local/lib64/libxkbcommon.so failed
attempt to open /usr/local/lib64/libxkbcommon.a failed
attempt to open /lib64/libxkbcommon.so succeeded
/lib64/libxkbcommon.so
libc.so needed by /lib64/libxkbcommon.so
attempt to open /usr/x86_64-unknown-linux-musl/lib64/libc.so failed
attempt to open /usr/local/lib64/libc.so failed
found libc.so at /lib64/libc.so
ld: warning: cannot find entry symbol _start; not setting start address
cplir-c commented 2 months ago

I successfully built kickoff for x86_64-unknown-linux-gnu using my void glibc chroot, but when I try to compile for x86_64-unknown-linux-musl I get the described linking error, and also when cross-compiling from gnu to musl.

j0ru commented 2 months ago

It seems that Void Linux doesn't include a statically compiled version of xkbcommon, but building it myself seems to have worked. Now I'm hanging on a lot of undefined reference errors from fontconfig and freetype...

j0ru commented 1 month ago

I have been banging my head against this on and off for the last couple of days and my largest problem at the moment is, that there seems to be no more static library for brotli, which breaks freetype, which breaks fontconfig, which breaks fontconfig-rs and therefore kickoff. Now, I can hardly imagine that it is impossible to statically link against fontconfig, which means that I went wrong somewhere, but I can't figure out where.

cplir-c commented 1 month ago

Why do you need to statically link the fontconfig transitive dependency only on musl libc?

Does fontconfig-rs build a static library by default?

j0ru commented 1 month ago

Tbh, I'm kind of out of my depth here. I rarely had to worry about how a binary was linked, so I'm stumbling from error message to error message, and currently I get a lot of these when trying to run cargo test on the fontconfig-rs crate:

          /usr/bin/ld: /usr/lib64/libfreetype.a(ftbzip2.o): in function `FT_Stream_OpenBzip2':
          (.text+0x613): undefined reference to `BZ2_bzDecompressInit'

The usual approach to get rid of these seems to be, to make sure a static library with that missing function is passed to the linker. I've been trying that until I ran into brotli :shrug:

If you have a good resource to learn those fundamentals, I would be very grateful!

cplir-c commented 1 month ago

I'm researching it a bit right now:

https://wiki.archlinux.org/title/Debugging#Missing_files_or_libraries https://wiki.gentoo.org/wiki/Why_not_bundle_dependencies#When_is_code_bundled.3F https://wiki.gentoo.org/wiki/Pkg-config optimizations like static linking allows symbol versioning https://wiki.gentoo.org/wiki/Writing_Rust_ebuilds https://rust-lang.github.io/rustup/cross-compilation.html configuring cargo with what linker to use for a specific target triple https://stackoverflow.com/questions/46934111/which-is-the-correct-way-to-build-a-static-library-with-link-time-code-generatio https://www.man7.org/linux/man-pages/man1/ar.1.html

cplir-c commented 1 month ago

Also, Archlinux has a musl package: https://wiki.archlinux.org/title/C#Alternative_libc_implementations list of files in musl package, note musl-gcc and musl-clang