Subject: bug#77800: grep-3.12: write-error-msg test failure on fedora rawhide (f43)

From: Paul Eggert <[email-masked]>
Date: Tue, 15 Apr 2025 11:52:14 -0700

Oh, sorry, I hadn't seen the email between you and Jim.

I am suspicious that rawhide gettext doesn't preserve errno. Could you 
please run the built grep under gdb as follows and say what happens to 
errno? The following transcript is on Fedora 41 where things work as 
expected (ENOSPC == 28):

$ gdb src/grep
GNU gdb (Fedora Linux) 16.2-2.fc41
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
     <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from src/grep...
(gdb) b close_stream
Breakpoint 1 at 0x41c300: file close-stream.c, line 57.
(gdb) r -q --help >/dev/full
Starting program: /home/eggert/src/gnu/grep/src/grep -q --help >/dev/full

This GDB supports auto-downloading debuginfo from the following URLs:
   <https://debuginfod.fedoraproject.org/>
Enable debuginfod for this session? (y or [n]) y
Debuginfod has been enabled.
To make this setting permanent, add 'set debuginfod enabled on' to .gdbinit.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Breakpoint 1, close_stream (stream=0x7ffff7ef15c0 <_IO_2_1_stdout_>)
     at close-stream.c:57
57	  const bool some_pending = (__fpending (stream) != 0);
(gdb) n
58	  const bool prev_fail = (ferror (stream) != 0);
(gdb) p some_pending
$1 = <optimized out>
(gdb) n
59	  const bool fclose_fail = (fclose (stream) != 0);
(gdb) n
69	  if (prev_fail || (fclose_fail && (some_pending || errno != EBADF)))
(gdb) p prev_fail
$2 = false
(gdb) p fclose_fail
$3 = true
(gdb) p some_pending
$4 = true
(gdb) p errno
$5 = 28
(gdb) n
close_stdout () at closeout.c:121
121	      char const *write_error = _("write error");
(gdb) n
122	      if (file_name)
(gdb) n
126	        error (0, errno, "%s", write_error);
(gdb) p errno
$6 = 28
(gdb) c
Continuing.
/home/eggert/src/gnu/grep/src/grep: write error: No space left on device
[Inferior 1 (process 96127) exited with code 02]
(gdb)