emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#27532: closed (getprogname: support for qemu)


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#27532: closed (getprogname: support for qemu)
Date: Sat, 01 Jul 2017 17:57:02 +0000

Your message dated Sat, 1 Jul 2017 10:56:06 -0700
with message-id <address@hidden>
and subject line Re: bug#27532: getprogname: support for qemu
has caused the debbugs.gnu.org bug report #27532,
regarding getprogname: support for qemu
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
27532: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=27532
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: getprogname: support for qemu Date: Thu, 29 Jun 2017 18:26:25 +0200 User-agent: KMail/5.1.3 (Linux/4.4.0-81-generic; KDE/5.18.0; x86_64; ; )
Hi,

When running the testsuite of grep-3.0 with qemu user mode, some tests fail.

How to reproduce:
- On a Debian or Ubuntu system, install package 'g++-5-aarch64-linux-gnu'.
- Install qemu-2.8.1 or qemu-2.9.0 from source.
- Prepare for executing aarch64 binaries:
  $ sudo update-binfmts --install qemu-aarch64 
$HOME/inst-qemu/2.8.1/bin/qemu-aarch64 --magic 
'\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00'
 --mask 
'\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
 --offset 0 --credential no
  $ QEMU_LD_PREFIX=/usr/aarch64-linux-gnu; export QEMU_LD_PREFIX
- $ ../configure --host=aarch64-linux CC="aarch64-linux-gnu-gcc-5"
- $ make
- $ make check

Test failure example:
filename-lineno.pl: test invalid-re: stderr mismatch, comparing invalid-re.1 
(expected) and invalid-re.E (actual)
*** invalid-re.1        Thu Jun 29 17:40:54 2017
--- invalid-re.E        Thu Jun 29 17:40:54 2017
***************
*** 1 ****
! grep: g:4: Unmatched [...
--- 1 ----
! /tmp/grep-3.0/build-arm64/src/grep: g:4: Unmatched [...

How come? The test suite invokes 'grep' from $PATH but:
1) When the x86_64 kernel is about to execute a native aarch64 binary, it
   prepares an argv with
     argv[0] = absolute file name of qemu-aarch64
     argv[1] = absolute file name of grep (it must be absolute, since it's not
               qemu's job to search for 'grep' in $PATH).
2) Inside grep, which is linked to glibc, the error() function used is the one
   from glibc. The one from gnulib, present in grep's source code, is not
   compiled. The error() function in glibc uses program_invocation_name,
   which is the absolute path of 'grep' by (1).
   The error() function in glibc does *not* use program_invocation_short_name,
   nor does it use gnulib's getprogname() which would also return
   program_invocation_short_name.

The following proof-of-concept patch fixes the problem - "make check" passes -,
but I don't know whether
  - you want something like this at all,
  - you want to limit it to the test situation. i.e. make the behaviour depend
    on some environment variable,
  - you prefer to fix the test suite instead (by removing the dirname of the
    program from the output before comparison with the expected result).

Bruno


--- grep-3.0/src/grep.c.bak     2017-02-09 02:37:33.000000000 +0100
+++ grep-3.0/src/grep.c 2017-06-29 18:07:53.072178500 +0200
@@ -2432,6 +2432,15 @@
   return result;
 }
 
+#if __GLIBC__ >= 2
+extern void (*error_print_progname) (void);
+static void
+error_print_program_invocation_short_name (void)
+{
+  fprintf (stderr, "%s: ", program_invocation_short_name);
+}
+#endif
+
 int
 main (int argc, char **argv)
 {
@@ -2445,6 +2454,10 @@
   int fread_errno;
   intmax_t default_context;
   FILE *fp;
+
+#if __GLIBC__ >= 2
+  error_print_progname = error_print_program_invocation_short_name;
+#endif
   exit_failure = EXIT_TROUBLE;
   initialize_main (&argc, &argv);
 




--- End Message ---
--- Begin Message --- Subject: Re: bug#27532: getprogname: support for qemu Date: Sat, 1 Jul 2017 10:56:06 -0700
On Sat, Jul 1, 2017 at 2:38 AM, Bruno Haible <address@hidden> wrote:
> Hi Jim,
>
>> Here's a patch that should address those others, too. Can you confirm
>> that it fixes those problems?
>
> Yes, with this patch, all 4 failures are gone, and "make check" proceeds
> to the gnulib tests, which also all succeed.

Thanks again. I've pushed it as
https://git.savannah.gnu.org/cgit/grep.git/commit/?id=9fbc2fb1823c71a9d3370e0b04886c5994000fa8


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]