https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101773

            Bug ID: 101773
           Summary: errors when writing to .gcda file are not checked
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: gcov-profile
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vincent-gcc at vinc17 dot net
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

When I run a program compiled with -fprofile-generate, this program creates a
.gcda file, but write/close errors are not checked. With GCC 12.0.0 20210729
built from master and an almost full file system for the .gcda file:

$ gcc-test -O -fprofile-generate=dir tst.c
$ strace ./a.out
[...]
openat(AT_FDCWD, "dir/#home#vlefevre#a-tst.gcda", O_RDWR|O_CREAT, 0666) = 3
fcntl(3, F_SETLKW, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
fcntl(3, F_GETFL)                       = 0x8002 (flags O_RDWR|O_LARGEFILE)
fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
read(3, "", 1024)                       = 0
lseek(3, 0, SEEK_SET)                   = 0
write(3, "adcg 02B\21\20\217\20\0\0\0\241\10\0\0\0\1\0\0\0\1\0\0\0\0\0\0\1"...,
84) = -1 ENOSPC (No space left on device)
close(3)                                = 0
exit_group(0)                           = ?
+++ exited with 0 +++

Note that with gcc (Debian 10.2.1-6) 10.2.1 20210110, I get an error message:

$ ./a.out
libgcov profiling error:dir/#home#vlefevre#tst.gcda:Error writing

but the exit status is also 0, so that the error cannot be detected in scripts.

Reply via email to