andrewgregory / pacutils

Helper library for libalpm based programs.
MIT License
107 stars 17 forks source link

paccheck crashes on ArchLinux32 #64

Closed VorpalBlade closed 1 week ago

VorpalBlade commented 1 year ago

This happens with the version from this repo as well as from the Arch32 package.

$ src/paccheck pacman
pacman: all dependencies satisfied
zsh: segmentation fault (core dumped)  src/paccheck pacman

Analysis with gdb:

(gdb) bt
#0  0xb7d1989a in strnlen () from /usr/lib/libc.so.6
#1  0xb7d197ac in strncpy () from /usr/lib/libc.so.6
#2  0x0040332b in check_files (pkg=0x427470) at paccheck.c:387
#3  0x00404c97 in main (argc=2, argv=0xbffff0d4) at paccheck.c:835
(gdb) up
#1  0xb7d197ac in strncpy () from /usr/lib/libc.so.6
(gdb) up
#2  0x0040332b in check_files (pkg=0x427470) at paccheck.c:387
387    strncpy(rel, file.name, space);
(gdb) print rel
$1 = 0xbfffdf8d "etc"
(gdb) print file.name
$2 = 0x0
(gdb) print space
$3 = 4095
(gdb) print file
$4 = {name = 0x0, size = 4973296, mode = 0}

Rebuilding like this fixes the issue:

make CFLAGS='-D_FILE_OFFSET_BITS=64' PREFIX=/

Presumably -D_FILE_OFFSET_BITS=64 needs to be set on 32-bit platforms. Maybe it is a mismatch in build flags between libalpm and pacutils?

Downstream Arch32 bug: https://bugs.archlinux32.org/index.php?do=details&task_id=317

VorpalBlade commented 1 year ago

There does seem to be additional issues on 32-bit, I cannot get the unit tests to pass. But that should probably be a separate bug.

solsticedhiver commented 1 week ago

that is a duplicate of #50 but since the comment https://github.com/solsticedhiver/pacutils/commit/60465531d515894c82308526fa4d22edad4c8f4b#commitcomment-74619227 in the related PR https://github.com/solsticedhiver/pacutils/commit/60465531d515894c82308526fa4d22edad4c8f4b nothing happened

andrewgregory commented 1 week ago

pkg-config libalpm --cflags should now be providing the required _FILE_OFFSET_BITS definition. If your build system is explicitly setting CFLAGS such that the Makefile isn't setting it, you can set it manually.