I'm able to build this app, but it stuck if try to run it while I use gdb to trace, and found it have problem to truncate int to char #include <unistd.h> int getopt(int argc, char *const argv[], const char *optstring); int fgetc(FILE *stream); the attached patch will just fix the problem Reproducible: Always
Created attachment 814120 [details, diff] psinfo-0.12-int.patch
this problem also exist at arm64 platform while according to RISC-V psAbi manual[1], "char" is equivalent to "unsigned char", so in RISC-V/ARM64 the following code will always print out false, while in X86_64 will print out true test() { char val = EOF; printf("%s", val == EOF ? "true" : "false"); } [1] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc C/C++ type representations char is unsigned.
(Just commit it at your leisure) Good find!
From 0bceea42308cb1cf5faa9665511a8e8468c491e5 Mon Sep 17 00:00:00 2001 From: Yixun Lan <dlan@gentoo.org> Date: Mon, 26 Sep 2022 20:08:08 +0800 Subject: [PATCH] fix 'char' issue in RISC-V (also Arm64) platform According to RISC-V psAbi manual[1], "char" is equivalent to "unsigned char", so in RISC-V/ARM64 the following code will always print out 'false', while in X86_64 it will print out 'true' test() { char val = EOF; printf("%s", val == EOF ? "true" : "false"); } According to man page, the following two function return value is 'int': int getopt(int argc, char *const argv[], const char *optstring); int fgetc(FILE *stream); so, we use 'int' variable and then convert to 'char' if nencessary [1] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc snip of description: C/C++ type representations char is unsigned. Bug: https://bugs.gentoo.org/872821 Signed-off-by: Yixun Lan <dlan@gentoo.org> I'll also try to report this to upstream (not sure if he can be reachable)..
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8d87286759fdff1a4ed2b9a36f7a1818e031e841 commit 8d87286759fdff1a4ed2b9a36f7a1818e031e841 Author: Yixun Lan <dlan@gentoo.org> AuthorDate: 2022-09-26 12:18:17 +0000 Commit: Yixun Lan <dlan@gentoo.org> CommitDate: 2022-09-26 12:21:35 +0000 sys-process/psinfo: fix 'unsigned char' issue in RISC-V/ARM64 platform Closes: https://bugs.gentoo.org/872821 Signed-off-by: Yixun Lan <dlan@gentoo.org> sys-process/psinfo/files/psinfo-0.12-char.patch | 65 +++++++++++++++++++++++++ sys-process/psinfo/psinfo-0.12-r1.ebuild | 3 +- 2 files changed, 67 insertions(+), 1 deletion(-)
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2e82ad643d809c8ac1cb5b92e46c10344e3c6be5 commit 2e82ad643d809c8ac1cb5b92e46c10344e3c6be5 Author: Sam James <sam@gentoo.org> AuthorDate: 2022-09-26 12:26:14 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2022-09-26 12:26:14 +0000 sys-process/psinfo: revbump for unsigned char fix it's only keyworded on amd64/x86, but it affects runtime and it'll avoid confusion if any say, arm users have been using it (or trying to). Closes: https://bugs.gentoo.org/872821 Signed-off-by: Sam James <sam@gentoo.org> sys-process/psinfo/psinfo-0.12-r1.ebuild | 1 - sys-process/psinfo/psinfo-0.12-r2.ebuild | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-)