You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@apr.apache.org by bu...@apache.org on 2018/11/19 21:19:52 UTC

[Bug 62927] New: apr_file_print says success on failure

https://bz.apache.org/bugzilla/show_bug.cgi?id=62927

            Bug ID: 62927
           Summary: apr_file_print says success on failure
           Product: APR
           Version: HEAD
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: APR
          Assignee: bugs@apr.apache.org
          Reporter: arekm@maven.pl
  Target Milestone: ---

Created attachment 36266
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=36266&action=edit
reproducer on Linux

apr_file_print() reports successfully written bytes even if there was a
failure:


# ./a.out
wrote 9 bytes

but it didn't write that 9 bytes to the file because:

openat(AT_FDCWD, "/sys/fs/cgroup/cpu/cgroup.procs", O_WRONLY|O_CLOEXEC) = 3
fcntl(3, F_GETFD)                       = 0x1 (flags FD_CLOEXEC)
write(3, "734389732", 9)                = -1 ESRCH (No such process)


Tested on Linux and apr 1.6.5

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


[Bug 62927] apr_file_print says success on failure

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62927

Arkadiusz Miskiewicz <ar...@maven.pl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Arkadiusz Miskiewicz <ar...@maven.pl> ---
I can also get

29086 openat(AT_FDCWD, "/sys/fs/cgroup/httpd/owner_4217/cgroup.procs",
O_WRONLY|O_CLOEXEC) = 3
29086 getpid()                          = 29086
29086 write(3, "29086", 5)              = -1 EACCES (Brak dostępu)
29086 close(3)                          = 0

but

23:49 < brane> arekm: second of all you should report APR bugs to the APR
project. but first of all ... what makes you assume that the error from writing
to a file in the /proc tree will be returned from apr_file_printf? because if
you got ESRCH then clearly the bytes _were_ written, right?
23:50 < brane> also it's likely that you don't want buffered I/O

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


[Bug 62927] apr_file_print says success on failure

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62927

--- Comment #5 from Arkadiusz Miskiewicz <ar...@maven.pl> ---
And matches ESRCH in strace:

22632 openat(AT_FDCWD, "/sys/fs/cgroup/cpu/cgroup.procs", O_WRONLY|O_CLOEXEC) =
3
22632 fcntl(3, F_GETFD)                 = 0x1 (flags FD_CLOEXEC)
22632 write(3, "734389732", 9)          = -1 ESRCH (No such process)
22632 fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
22632 write(1, "THIS MESSAGE SHOULD BE PRINTED No such process\n", 47) = 47

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


[Bug 62927] apr_file_print says success on failure

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62927

--- Comment #4 from Arkadiusz Miskiewicz <ar...@maven.pl> ---
 ./a.out
THIS MESSAGE SHOULD BE PRINTED No such process


works (tested on 1.6.5) + that patch

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


[Bug 62927] apr_file_print says success on failure

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62927

Arkadiusz Miskiewicz <ar...@maven.pl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|INVALID                     |---
     Ever confirmed|1                           |0
             Status|RESOLVED                    |UNCONFIRMED

--- Comment #2 from Arkadiusz Miskiewicz <ar...@maven.pl> ---
On the other hand regular write(2) is:

"RETURN VALUES
     Upon successful completion the number of bytes which were written is
returned.  Otherwise, a -1 is returned and the global variable errno is set to
indicate the error."

so it doesn't matter if bytes are written. If there is an error then there is a
error.

Is apr trying to mimic such behaviour?

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


[Bug 62927] apr_file_print says success on failure

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62927

--- Comment #3 from Yann Ylavic <yl...@gmail.com> ---
Created attachment 36269
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=36269&action=edit
Report flush failure

What about with this patch applied ?

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org