On Sun, Aug 28, 2016 at 03:50:04AM +0300, Andrey Chernov wrote: > On 28.08.2016 3:38, Andrey Chernov wrote: > > On 28.08.2016 2:03, Konstantin Belousov wrote: > >> Since ptrace(2) syscall can return -1 for non-error situations, libc > >> wrappers set errno to 0 before performing the syscall, as the service > >> to the caller. > > > > Both C99 and POSIX directly prohibits any standard function to set errno > > to 0. ptrace() should either choose other errno to indicate non-error > > situation or change return -1 to something else. > > > ...and don't touch errno. > > POSIX: "No function in this volume of POSIX.1-2008 shall set errno to zero." I am quite curious where ptrace(2) is defined by POSIX.
> > > On both i386 and amd64, the errno symbol was directly > > referenced, which only works correctly in single-threaded process. > > POSIX: "For each thread of a process, the value of errno shall not be > affected by function calls or assignments to errno by other threads." And ? What should the citation add new to the substance of the code change ? On Sun, Aug 28, 2016 at 04:04:00AM +0300, Andrey Chernov wrote: > On 28.08.2016 3:56, Konstantin Belousov wrote: > > On Sun, Aug 28, 2016 at 03:38:10AM +0300, Andrey Chernov wrote: > >> On 28.08.2016 2:03, Konstantin Belousov wrote: > >>> Since ptrace(2) syscall can return -1 for non-error situations, libc > >>> wrappers set errno to 0 before performing the syscall, as the service > >>> to the caller. > >> > >> Both C99 and POSIX directly prohibits any standard function to set errno > >> to 0. ptrace() should either choose other errno to indicate non-error > >> situation or change return -1 to something else. > >> > > ptrace(2) is not a standard function. > > And, we cannot break ABI for the syscall. > > > > C99 statement sounds stricter: > "The value of errno is zero at program startup, but is never set to zero > by any library function. 176)" > And syscall is not different from library function from C99 point of view. Point me to a single line in C99 which mentions ptrace(). Do you understand what did the commit changed, and what it did not ? Setting errno to zero before the syscall was the existing behaviour before the change, and I did not modified anything there. But previous wrapper set errno to zero in main thread even if called from some other thread, which was the bug fixed. _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"