public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug stdio/16724] New: offset computation in ftell is incorrect when a read is followed by a write for files opened in a+ mode
@ 2014-03-18 20:18 siddhesh at redhat dot com
  2014-03-20 14:23 ` [Bug stdio/16724] " erik.m.bray at gmail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: siddhesh at redhat dot com @ 2014-03-18 20:18 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16724

            Bug ID: 16724
           Summary: offset computation in ftell is incorrect when a read
                    is followed by a write for files opened in a+ mode
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: stdio
          Assignee: siddhesh at redhat dot com
          Reporter: siddhesh at redhat dot com

ftell reports an incorrect offset when a file opened in a+ mode is first read
from and then written to.  This is because the assumption of _IO_read_end
coinciding with the external file position is not correct when O_APPEND is in
effect.

Fix coming up.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug stdio/16724] offset computation in ftell is incorrect when a read is followed by a write for files opened in a+ mode
  2014-03-18 20:18 [Bug stdio/16724] New: offset computation in ftell is incorrect when a read is followed by a write for files opened in a+ mode siddhesh at redhat dot com
@ 2014-03-20 14:23 ` erik.m.bray at gmail dot com
  2014-03-20 14:43 ` siddhesh at redhat dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: erik.m.bray at gmail dot com @ 2014-03-20 14:23 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16724

Erik Bray <erik.m.bray at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |erik.m.bray at gmail dot com

--- Comment #1 from Erik Bray <erik.m.bray at gmail dot com> ---
I'm glad you reported this.  I just discovered this issue myself in the context
of some tests for my library failing on Fedora 21:
https://github.com/astropy/astropy/issues/2168  Good to see this is in fact a
bug and I'm not crazy.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug stdio/16724] offset computation in ftell is incorrect when a read is followed by a write for files opened in a+ mode
  2014-03-18 20:18 [Bug stdio/16724] New: offset computation in ftell is incorrect when a read is followed by a write for files opened in a+ mode siddhesh at redhat dot com
  2014-03-20 14:23 ` [Bug stdio/16724] " erik.m.bray at gmail dot com
@ 2014-03-20 14:43 ` siddhesh at redhat dot com
  2014-03-24 15:49 ` erik.m.bray at gmail dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: siddhesh at redhat dot com @ 2014-03-20 14:43 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16724

--- Comment #2 from Siddhesh Poyarekar <siddhesh at redhat dot com> ---
I have posted a patch here:

https://sourceware.org/ml/libc-alpha/2014-03/msg00578.html

It would be great if you could try it out and give feedback.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug stdio/16724] offset computation in ftell is incorrect when a read is followed by a write for files opened in a+ mode
  2014-03-18 20:18 [Bug stdio/16724] New: offset computation in ftell is incorrect when a read is followed by a write for files opened in a+ mode siddhesh at redhat dot com
  2014-03-20 14:23 ` [Bug stdio/16724] " erik.m.bray at gmail dot com
  2014-03-20 14:43 ` siddhesh at redhat dot com
@ 2014-03-24 15:49 ` erik.m.bray at gmail dot com
  2014-05-27  8:25 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: erik.m.bray at gmail dot com @ 2014-03-24 15:49 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16724

--- Comment #3 from Erik Bray <erik.m.bray at gmail dot com> ---
Sorry for the delay, but I have confirmation that with this patch the issue as
we experienced it is fixed.  Thanks!

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug stdio/16724] offset computation in ftell is incorrect when a read is followed by a write for files opened in a+ mode
  2014-03-18 20:18 [Bug stdio/16724] New: offset computation in ftell is incorrect when a read is followed by a write for files opened in a+ mode siddhesh at redhat dot com
                   ` (2 preceding siblings ...)
  2014-03-24 15:49 ` erik.m.bray at gmail dot com
@ 2014-05-27  8:25 ` cvs-commit at gcc dot gnu.org
  2014-05-27  8:28 ` siddhesh at redhat dot com
  2014-06-13  9:18 ` fweimer at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2014-05-27  8:25 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16724

--- Comment #4 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  2482ae433a4249495859343ae1fba408300f2c2e (commit)
      from  bab900166e8b5f0f4081c5cf1afa0cd33b123714 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=2482ae433a4249495859343ae1fba408300f2c2e

commit 2482ae433a4249495859343ae1fba408300f2c2e
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
Date:   Tue May 27 13:54:19 2014 +0530

    Fix offset computation for append+ mode on switching from read (BZ #16724)

    The offset computation in write mode uses the fact that _IO_read_end
    is kept in sync with the external file offset.  This however is not
    true when O_APPEND is in effect since switching to write mode ought to
    send the external file offset to the end of file without making the
    necessary adjustment to _IO_read_end.

    Hence in append mode, offset computation when writing should only
    consider the effect of unflushed writes, i.e. from _IO_write_base to
    _IO_write_ptr.

    The wiki has a detailed document that describes the rationale for
    offsets returned by ftell in various conditions:

   
https://sourceware.org/glibc/wiki/File%20offsets%20in%20a%20stdio%20stream%20and%20ftell

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                |    9 +++
 NEWS                     |   10 ++--
 libio/Makefile           |    4 +-
 libio/fileops.c          |   12 +++-
 libio/tst-ftell-append.c |  169 ++++++++++++++++++++++++++++++++++++++++++++++
 libio/wfileops.c         |   13 +++-
 6 files changed, 207 insertions(+), 10 deletions(-)
 create mode 100644 libio/tst-ftell-append.c

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug stdio/16724] offset computation in ftell is incorrect when a read is followed by a write for files opened in a+ mode
  2014-03-18 20:18 [Bug stdio/16724] New: offset computation in ftell is incorrect when a read is followed by a write for files opened in a+ mode siddhesh at redhat dot com
                   ` (3 preceding siblings ...)
  2014-05-27  8:25 ` cvs-commit at gcc dot gnu.org
@ 2014-05-27  8:28 ` siddhesh at redhat dot com
  2014-06-13  9:18 ` fweimer at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: siddhesh at redhat dot com @ 2014-05-27  8:28 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16724

Siddhesh Poyarekar <siddhesh at redhat dot com> changed:

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

--- Comment #5 from Siddhesh Poyarekar <siddhesh at redhat dot com> ---
Fixed in master.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug stdio/16724] offset computation in ftell is incorrect when a read is followed by a write for files opened in a+ mode
  2014-03-18 20:18 [Bug stdio/16724] New: offset computation in ftell is incorrect when a read is followed by a write for files opened in a+ mode siddhesh at redhat dot com
                   ` (4 preceding siblings ...)
  2014-05-27  8:28 ` siddhesh at redhat dot com
@ 2014-06-13  9:18 ` fweimer at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: fweimer at redhat dot com @ 2014-06-13  9:18 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16724

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-06-13  9:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-18 20:18 [Bug stdio/16724] New: offset computation in ftell is incorrect when a read is followed by a write for files opened in a+ mode siddhesh at redhat dot com
2014-03-20 14:23 ` [Bug stdio/16724] " erik.m.bray at gmail dot com
2014-03-20 14:43 ` siddhesh at redhat dot com
2014-03-24 15:49 ` erik.m.bray at gmail dot com
2014-05-27  8:25 ` cvs-commit at gcc dot gnu.org
2014-05-27  8:28 ` siddhesh at redhat dot com
2014-06-13  9:18 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).