Open Mr-Andersen opened 4 months ago
Using this overlay to downgrade back to 2023.04
worked for me to fix the segfault. Note that you might have to delete ~/.config/koreader/cache/fontlist/
:
(self: super: {
koreader = super.koreader.overrideAttrs (old: let
luajit_lua52 = super.luajit.override { enable52Compat = true; };
src_repo = super.fetchFromGitHub {
repo = "koreader";
owner = "koreader";
rev = "v2023.04";
fetchSubmodules = true;
hash = "sha256-c3j6hs0W0H2jDg6JVfU6ov7r7kucbqrQqf9PAvYBcJ0=";
};
src = super.fetchurl {
url = "https://github.com/koreader/koreader/releases/download/v2023.04/koreader-2023.04-amd64.deb";
hash = "sha256-tRUeRB1+UcWT49dchN0YDvd0L5n1YRdtMSFc8yy6m5o=";
};
in {
version = "2023.04";
unpackCmd = "dpkg-deb -x ${src} .";
installPhase = ''
mkdir -p $out
cp -R usr/* $out/
ln -sf ${luajit_lua52}/bin/luajit $out/lib/koreader/luajit
ln -sf ${super.sdcv}/bin/sdcv $out/lib/koreader/sdcv
ln -sf ${super.gnutar}/bin/tar $out/lib/koreader/tar
find ${src_repo}/resources/fonts -type d -execdir cp -r '{}' $out/lib/koreader/fonts \;
find $out -xtype l -print -delete
wrapProgram $out/bin/koreader --prefix LD_LIBRARY_PATH : ${
lib.makeLibraryPath [ super.gtk3-x11 super.SDL2 super.glib ]
}
'';
});
})
The stack trace isn't very helpful because of the Lua runtime:
Stack trace of thread 519576:
#0 0x00007fb2649d45be free (libc.so.6 + 0x9e5be)
#1 0x00007fb23d02e00a ZSTD_compress (/nix/store/4hscmwibkgq7lpg26sdz19mhw12l74bh-koreader-2024.04/lib/koreader/libs/libzstd.so.1 + 0x2e00a)
#2 0x0000000000471009 n/a (luajit-2.1.1713773202 + 0x71009)
#3 0x000000000044f453 n/a (luajit-2.1.1713773202 + 0x4f453)
#4 0x000000000044fc6d n/a (luajit-2.1.1713773202 + 0x4fc6d)
#5 0x000000000046eb7b n/a (luajit-2.1.1713773202 + 0x6eb7b)
#6 0x000000000045fcbe n/a (luajit-2.1.1713773202 + 0x5fcbe)
#7 0x000000000046eb7b n/a (luajit-2.1.1713773202 + 0x6eb7b)
#8 0x000000000045fcbe n/a (luajit-2.1.1713773202 + 0x5fcbe)
#9 0x000000000046eb7b n/a (luajit-2.1.1713773202 + 0x6eb7b)
#10 0x000000000045fcbe n/a (luajit-2.1.1713773202 + 0x5fcbe)
#11 0x000000000046eb7b n/a (luajit-2.1.1713773202 + 0x6eb7b)
#12 0x000000000045fcbe n/a (luajit-2.1.1713773202 + 0x5fcbe)
#13 0x000000000046eb7b n/a (luajit-2.1.1713773202 + 0x6eb7b)
#14 0x000000000046187c n/a (luajit-2.1.1713773202 + 0x6187c)
#15 0x000000000046eb7b n/a (luajit-2.1.1713773202 + 0x6eb7b)
#16 0x000000000046187c n/a (luajit-2.1.1713773202 + 0x6187c)
#17 0x000000000046eb7b n/a (luajit-2.1.1713773202 + 0x6eb7b)
#18 0x00000000004600fc lua_pcall (luajit-2.1.1713773202 + 0x600fc)
#19 0x000000000040587b n/a (luajit-2.1.1713773202 + 0x587b)
#20 0x0000000000406aaf n/a (luajit-2.1.1713773202 + 0x6aaf)
#21 0x000000000046eb7b n/a (luajit-2.1.1713773202 + 0x6eb7b)
#22 0x000000000046027d lua_cpcall (luajit-2.1.1713773202 + 0x6027d)
#23 0x00000000004056da main (luajit-2.1.1713773202 + 0x56da)
#24 0x00007fb26496010e __libc_start_call_main (libc.so.6 + 0x2a10e)
#25 0x00007fb2649601c9 __libc_start_main@@GLIBC_2.34 (libc.so.6 + 0x2a1c9)
#26 0x0000000000405755 _start (luajit-2.1.1713773202 + 0x5755)
But at least we know it's failing at the built-in libzstd call with ~/.config/koreader/cache/fontlist/fontinfo.dat
now.
I managed to get 2024.04 (unstable channel) and the latest 2024.07 running by replacing the built-in libzstd with nixpkgs one:
{
lib,
stdenv,
fetchurl,
makeWrapper,
fetchFromGitHub,
dpkg,
glib,
gnutar,
gtk3-x11,
luajit,
sdcv,
SDL2,
zstd,
}:
let
luajit_lua52 = luajit.override {enable52Compat = true;};
in
stdenv.mkDerivation rec {
pname = "koreader";
version = "2024.07";
src =
if stdenv.isAarch64
then
fetchurl {
url = "https://github.com/koreader/koreader/releases/download/v${version}/koreader-${version}-arm64.deb";
hash = "sha256-KrkY1lTwq8mIomUUCQ9KvfZqinJ74Y86fkPexsFiOPg=";
}
else
fetchurl {
url = "https://github.com/koreader/koreader/releases/download/v${version}/koreader-${version}-amd64.deb";
hash = "sha256-Xs9Ci5a3FntRwb6kkn1dCGh62pjj/TF154IG1uiDpRQ=";
};
src_repo = fetchFromGitHub {
repo = "koreader";
owner = "koreader";
rev = "v${version}";
fetchSubmodules = true;
hash = "sha256-IBGyjw9mzSOBY4GpeHab+aUYh1+Sb0ErfQsc2goO3cM=";
};
sourceRoot = ".";
nativeBuildInputs = [makeWrapper dpkg];
buildInputs = [
glib
gnutar
gtk3-x11
luajit_lua52
sdcv
SDL2
zstd.out
];
unpackCmd = "dpkg-deb -x ${src} .";
dontConfigure = true;
dontBuild = true;
installPhase = ''
mkdir -p $out
cp -R usr/* $out/
ln -sf ${luajit_lua52}/bin/luajit $out/lib/koreader/luajit
ln -sf ${sdcv}/bin/sdcv $out/lib/koreader/sdcv
ln -sf ${gnutar}/bin/tar $out/lib/koreader/tar
ln -sf ${zstd.out}/lib/libzstd.so $out/lib/koreader/libs/libzstd.so.1
find ${src_repo}/resources/fonts -type d -execdir cp -r '{}' $out/lib/koreader/fonts \;
find $out -xtype l -print -delete
wrapProgram $out/bin/koreader --prefix LD_LIBRARY_PATH : ${
lib.makeLibraryPath [gtk3-x11 SDL2 glib stdenv.cc.cc.lib]
}
'';
meta = with lib; {
homepage = "https://github.com/koreader/koreader";
changelog = "https://github.com/koreader/koreader/releases/tag/v${version}";
description = "An ebook reader application supporting PDF, DjVu, EPUB, FB2 and many more formats, running on Cervantes, Kindle, Kobo, PocketBook and Android devices";
mainProgram = "koreader";
sourceProvenance = with sourceTypes; [binaryNativeCode];
platforms = ["aarch64-linux" "x86_64-linux"];
license = licenses.agpl3Only;
maintainers = with maintainers; [contrun neonfuz];
};
}
However, this is really fragile and prone to breaking, so I won't open PR myself (but anyone is free to do so).
Failed to allocate ZSTD decompression buffer
error occurs during one time data migration to the latest version, so I was forced to do rm -rf ~/.config/koreader
to get it running.
Ideally, packages like this should be built from source, but koreader seems very complicated.
Note that koreader also performs migration on the first run, it's not possible to just install it for the first time and use it right now. @jys1670 can you open PR please?
Describe the bug
KOReader fails with segmentation fault on every startup.
Steps To Reproduce
Steps to reproduce the behavior:
nix run github:NixOS/nixpkgs/805a384895c696f802a9bf5bf4720f37385df547#koreader
Expected behavior
KOReader starts up.
Logs
Notify maintainers
@contrun @neonfuz
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result.