This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/6771] New: %m specifier in dprintf doesn't work as errno clobbered before output


Using the "%m" (error string) specifier in dprintf() does not work when the 
file descriptor is non-seekable. lseek() is called on the file descriptor and 
sets errno to ESPIPE. Then it appears the actual formatting and outputting is 
done. This causes the %m in the output to always report "Illegal seek".

I attach a simple test program which illustrates the problem.

An excerpt of the strace output from this program illuminates the problem:

unlink("nonexistent")                   = -1 ENOENT (No such file or directory)
fstat(2, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 10), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x7f8edefb8000
lseek(2, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
write(2, "Error: Illegal seek\n", 20)   = 20

The expected behaviour would be for the original value of errno to be restarted 
after the lseek(), so that %m would output (in this case) "No such file or 
directory".

I am using what Gentoo refer to as "2.8_p20080602".

-- 
           Summary: %m specifier in dprintf doesn't work as errno clobbered
                    before output
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: l at lwithers dot me dot uk
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=6771

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]