aurman fails to run on Raspberry Pi 2
hansheijmans opened this issue · comments
Description
I wanted to update my Archlinux on my Raspberry Pi 2 like I used to do every one or two weeks. After the latest update using aurman (in which aurman itself was updated also from 2.14 to 2.16) I ran into this issue. Apparently this issue only appears on my Raspberry Pi 2 armv7h platform. On x86_64 the error did not appear.
Expected Behavior
aurman --version
should return 2.16-1 or anything similar
Current Behavior
This is what I got:
2018-07-04 23:10:34,521 - wrappers - expac - ERROR - expac query -Q %v - for targets ['aurman-git', 'aurman'] failed
2018-07-04 23:10:34,523 - main - main - ERROR -
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/aurman/main.py", line 835, in main
process(argv[1:])
File "/usr/lib/python3.6/site-packages/aurman/main.py", line 345, in process
show_version()
File "/usr/lib/python3.6/site-packages/aurman/main.py", line 85, in show_version
aurman_note(expac("-Q", ["v"], ["aurman-git", "aurman"])[0])
File "/usr/lib/python3.6/site-packages/aurman/wrappers.py", line 69, in expac
raise InvalidInput("expac query {} for targets {} failed".format(query_stringified, targets))
aurman.own_exceptions.InvalidInput: expac query -Q %v - for targets ['aurman-git', 'aurman'] failed
Possible Solution
Sorry, I wouldn't know, seems related to platform.
Version of aurman you are using
Latest package on AUR (2.16-1)
Steps to Reproduce
aurman --version
or-V
- Also tried
aurman -Syu
with similar result:
2018-07-04 23:20:40,564 - wrappers - expac - ERROR - expac query -Q '%n?!%v?!%D?!%H?!%o?!%P?!%T?!%e?!%G?!%w' - for targets ['faad2', 'bash', ...........] failed
- Tried updating expac-git manually from AUR --> no change in behaviour
- Tried replacing expac-git by expac from stable --> no change in behaviour
Read the README
Yes, I did!
Running linux distribution
Linux RPIarch 4.14.52-1-ARCH #1 SMP Thu Jun 28 00:45:47 UTC 2018 armv7l GNU/Linux
What is the output of this printf "%s\n" aurman aurman-git expac expac-git | expac -Q "%n %v" -
command? Do not miss the -
at the end of the command.
@polygamma ,
error: buffer overflow on stdin
both as regular user and as root
Typo?
Nope, definitely not a typo, seems to be a problem with Arch Linux ARM. I am not sure if I am able to help you, to be honest, maybe @eli-schwartz, @AladW or @Morganamilo know something about this?
I can say for sure, that it has something to do with how expac
is being called since aurman 2.16
, see b56691d#diff-1d9d6ff44724af9296e5dec4a6802a28R61 and the relevant discussion here: #171 (diff)
I am going to investigate, but I am not very confident that I am able to say what the real problem is, since I am not using Arch Linux ARM. Btw. for reference, when I run the command:
[jonny@jonny-arch-pc ~]$ printf "%s\n" aurman aurman-git expac expac-git | expac -Q "%n %v" -
aurman-git 2.16.r6.g8da4f35-1
expac 9-1
Addition: The error message comes from here: https://github.com/falconindy/expac/blob/master/expac.c#L822
@polygamma , thanks for your time! Will keep monitoring this thread.
please paste the following into a file called test.c
:
#include <stdio.h>
int main() {
printf("BUFSIZ: %d\n", BUFSIZ);
return 0;
}
go with cd
into that folder and execute gcc test.c -o test && ./test
and post the output.
For further reference see e.g. https://www.gnu.org/software/libc/manual/html_node/Controlling-Buffering.html
The size should be at least 256
, but it seems like it's not on your system.
@hansheijmans - please install expac-git
via the following PKGBUILD
# Contributor: Dave Reisner <d@falconindy.com>
pkgname=expac-git
pkgver=9
pkgrel=2
pkgdesc="pacman database extraction utility"
arch=('i686' 'x86_64')
url="http://github.com/falconindy/expac"
license=('MIT')
depends=('pacman')
makedepends=('git' 'perl')
conflicts=('expac')
provides=('expac')
source=('git://github.com/falconindy/expac.git'
'https://pastebin.com/raw/mxExySAd')
md5sums=('SKIP'
'SKIP')
prepare() {
cd $srcdir
patch expac/expac.c mxExySAd
}
pkgver() {
cd expac
git describe | sed 's/-/./g'
}
build() {
cd expac
make
}
package() {
cd expac
make PREFIX=/usr DESTDIR="$pkgdir" install
}
# vim: ft=sh syn=sh et
it installs the current expac-git
version, but applies the following patch for debugging purposes:
From 2334e8fb9c3a4e6edfe21bd96df8cfa60994dcb3 Mon Sep 17 00:00:00 2001
From: Jonni Westphalen <jonny.westphalen@googlemail.com>
Date: Thu, 5 Jul 2018 12:14:14 +0200
Subject: [PATCH] expac debug
---
expac.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/expac.c b/expac.c
index 3528e06..118a510 100644
--- a/expac.c
+++ b/expac.c
@@ -799,14 +799,19 @@ static int read_targets_from_file(FILE *in, alpm_list_t **targets)
{
char line[BUFSIZ];
int i = 0, end = 0, targets_added = 0;
+ unsigned int global_counter = 0;
while(!end) {
line[i] = fgetc(in);
+ printf("char %u: %c\n", ++global_counter, line[i]);
- if(line[i] == EOF)
+ if(line[i] == EOF) {
+ printf("EOF reached at global char %u\n", global_counter);
end = 1;
+ }
if(isspace(line[i]) || end) {
+ printf("char %c is end or space, replacing with nullterminator\n", line[i]);
line[i] = '\0';
/* avoid adding zero length arg, if multiple spaces separate args */
if(i > 0) {
@@ -823,6 +828,8 @@ static int read_targets_from_file(FILE *in, alpm_list_t **targets)
return -1;
}
}
+
+ printf("\n");
}
return targets_added;
--
2.18.0
after that, post the full output of the following command you already ran:
printf "%s\n" aurman aurman-git expac expac-git | expac -Q "%n %v" -
Nevermind: I know what the problem is, char
is unsigned on ARM, the return value of fgetc
is going to be casted to something besides EOF
all the time, because it is being saved in a char[]
, thus never as -1
, thus line[i] == EOF
is never true and thus the overflow. Going to prepare a proper patch and open a PR in the expac repo.
@polygamma You can try it by yourself under your x86_64 Arch Linux.
- Become root user: sudo su
- Install emulation software: qemu-user-static and binfmt-support-git from AUR
- Download ArchLinux ARM (armv7) image: wget http://os.archlinuxarm.org/os/ArchLinuxARM-armv7-latest.tar.gz
- Make empty disk image: dd if=/dev/zero of=diskimage bs=1M count=8092
- Create EXT-4 filesystem on it: mkfs.ext4 -F diskimage
- Make directory to mount: mkdir alarmv7
- Mount disk image: mount diskimage alarmv7
- Unpack Arch Linux ARM system files: bsdtar -xf ArchLinuxARM-armv7-latest.tar.gz -C alarmv7
- Copy emulation module into it: cp /usr/bin/qemu-arm-static alarmv7/usr/bin
- Chroot into system: chroot alarmv7
- Check network: ping 8.8.8.8, it should work now
- Remove symlink to systemd resolv.conf: rm /etc/resolv.conf
- Setup nameserver: echo "nameserver 8.8.8.8" > /etc/resolv.conf
- Check web: ping google.com
Now you're in Arch LInux ARM with 8GB memory and network connection. Hope it will be useful.
step 10 yields: chroot: failed to run command ‘/bin/bash’: Exec format error
By following https://gist.github.com/mikkeloscar/a85b08881c437795c1b9 I was able to get it running, I have built expac-git
including my fix found here: falconindy/expac@8d6429b and can confirm, that it indeed fixes the issue, see:
[root@jonny-arch-pc /]# printf "%s\n" aurman aurman-git expac expac-git | expac -Q "%n %v" -
expac-git 9.1.gd15538e-1
Going to open a PR in the expac
repo.
done, see: falconindy/expac#37
The PR has been merged, you may use expac-git
as of now and everything should work again.
added FAQ entry: 5481a5a