Skip to content

mmap requires file to be synced #56311

Closed
Closed

Description

@rion4ikgmailcom
BPO 12102
Nosy @vstinner
Files
  • 12102.2.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2011-07-25.05:26:23.708>
    created_at = <Date 2011-05-18.09:56:03.768>
    labels = ['type-bug']
    title = 'mmap requires file to be synced'
    updated_at = <Date 2011-07-25.05:26:23.707>
    user = 'https://bugs.python.org/rion4ikgmailcom'

    bugs.python.org fields:

    activity = <Date 2011-07-25.05:26:23.707>
    actor = 'rosslagerwall'
    assignee = 'rosslagerwall'
    closed = True
    closed_date = <Date 2011-07-25.05:26:23.708>
    closer = 'rosslagerwall'
    components = ['None']
    creation = <Date 2011-05-18.09:56:03.768>
    creator = 'rion4ik@gmail.com'
    dependencies = []
    files = ['22048']
    hgrepos = []
    issue_num = 12102
    keywords = ['patch']
    message_count = 14.0
    messages = ['136217', '136218', '136220', '136221', '136236', '136237', '136242', '136243', '136434', '136452', '136545', '141069', '141070', '141071']
    nosy_count = 6.0
    nosy_names = ['vstinner', 'schmir', 'rosslagerwall', 'sdaoden', 'python-dev', 'rion4ik@gmail.com']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue12102'
    versions = ['Python 2.7', 'Python 3.2', 'Python 3.3']

    Activity

    1. rion4ikgmailcom commented on May 18, 2011

      rion4ikgmailcommannequin
      MannequinAuthor

      Not flushed file gives next results:

      rion@rionhost ~/temp $ python2 test.py 
      Traceback (most recent call last):
        File "test.py", line 10, in <module>
          m = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
      mmap.error: [Errno 22] Invalid argument
      rion@rionhost ~/temp $ python3 test.py 
      Traceback (most recent call last):
        File "test.py", line 10, in <module>
          m = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
      ValueError: mmap offset is greater than file size

      testcase:

      import mmap
      from tempfile import TemporaryFile
      
      f = TemporaryFile()
      f.write(b"hello world")

      #f.flush()

      m = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)

      just uncomment f.flush() and try again. feel the difference.

      suggestion: force flush on file descriptor when passed to mmap.

    2. schmir commented on May 18, 2011

      schmirmannequin
      Mannequin

      your suggestion doesn't work. there's no such thing like a "flush on file descriptor".

    3. vstinner commented on May 18, 2011

      @vstinner
      Member

      See also issue bpo-11877 and bpo-11277.

    4. rion4ikgmailcom commented on May 18, 2011

      rion4ikgmailcommannequin
      MannequinAuthor

      okay guys I'm not going to read all this stuff.
      just document it or fix.

      thanks for quick reply

    5. sdaoden commented on May 18, 2011

      sdaodenmannequin
      Mannequin

      @ rion wrote (2011-05-18 12:39+0200):

      just document it or fix.

      Hello, zion, Victor, i'm proposing a documentation patch.
      It applies to 2.7 and 3.3 (from yesterday).

    6. vstinner commented on May 18, 2011

      @vstinner
      Member

      Hello, zion, Victor, i'm proposing a documentation patch.

      I like it.

      I don't think that Python should guess what the user expects (i.e. Python should not sync the file *implicitly*).

    7. sdaoden commented on May 18, 2011

      sdaodenmannequin
      Mannequin

      @ STINNER Victor wrote (2011-05-18 14:33+0200):

      I don't think that Python should guess what the user expects
      (i.e. Python should not sync the file *implicitly*).

      Before i've found F_FULLFSYNC i indeed have had a solution which
      tracked the open() of all files, so that mmap() could check wether
      a file had been opened in write mode or not. ;|
      Python does not do that by default (AFAIK).

    8. rosslagerwall commented on May 18, 2011

      rosslagerwallmannequin
      Mannequin

      I don't think that Python should guess what the user expects (i.e. Python should not sync the file *implicitly*).

      Agreed.

      The documentation patch looks good.

    9. sdaoden commented on May 21, 2011

      sdaodenmannequin
      Mannequin

      Looked at it again and i think it's much better english with an
      additional ..to ensure "that" local...
      @ross, aren't you a native english speaker? What do you say?

    10. rosslagerwall commented on May 21, 2011

      rosslagerwallmannequin
      Mannequin

      Looked at it again and i think it's much better english with an
      additional ..to ensure "that" local...
      @ross, aren't you a native english speaker? What do you say?

      Yes I am, but that doesn't make me any good ;-)

      I'd probably agree that it's better with "that" included.

    11. sdaoden commented on May 22, 2011

      sdaodenmannequin
      Mannequin

      that doesn't make me any good

      Well - 'can only be better than myself, so i'll take that as yes :)

    12. python-dev commented on Jul 25, 2011

      python-devmannequin
      Mannequin

      New changeset 198627bbe242 by Ross Lagerwall in branch '3.2':
      Issue bpo-12102: Document that buffered files must be flushed before being used
      http://hg.python.org/cpython/rev/198627bbe242

      New changeset 4898b14dcd69 by Ross Lagerwall in branch 'default':
      Issue bpo-12102: Merge with 3.2.
      http://hg.python.org/cpython/rev/4898b14dcd69

    13. python-dev commented on Jul 25, 2011

      python-devmannequin
      Mannequin

      New changeset e75715f27ce7 by Ross Lagerwall in branch '2.7':
      Issue bpo-12102: Document that buffered files must be flushed before being used
      http://hg.python.org/cpython/rev/e75715f27ce7

    14. rosslagerwall commented on Jul 25, 2011

      rosslagerwallmannequin
      Mannequin

      Thanks!

    15. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      type-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions