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

--- Comment #6 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> ---
Created attachment 51259
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51259&action=edit
added missing error check on fclose in gcc/gcov-io.c

Well, not all errors are detected. There is a missing test in gcc/gcov-io.c for
fclose (which does a write system call to flush the buffers):

--- a/gcc/gcov-io.c
+++ b/gcc/gcov-io.c
@@ -199,7 +199,8 @@ gcov_close (void)
 {
   if (gcov_var.file)
     {
-      fclose (gcov_var.file);
+      if (fclose (gcov_var.file))
+       gcov_var.error = 1;
       gcov_var.file = 0;
     }
   gcov_var.mode = 0;

(also in attachment). I've tested this patch, and it solves my problem:

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\233\10\222\21\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
write(2, "libgcov profiling error:dir/#hom"..., 68libgcov profiling
error:dir/#home#vlefevre#a-tst.gcda:Error writing
) = 68
write(2, "profiling:exiting after an error"..., 33profiling:exiting after an
error
) = 33
exit_group(1)                           = ?
+++ exited with 1 +++

Reply via email to