Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mmap\'s resize method resizes the file in win32 but not unix #38382

Closed
myerscarpenter mannequin opened this issue Apr 27, 2003 · 9 comments
Closed

mmap\'s resize method resizes the file in win32 but not unix #38382

myerscarpenter mannequin opened this issue Apr 27, 2003 · 9 comments
Assignees
Labels
extension-modules C modules in the Modules dir

Comments

@myerscarpenter
Copy link
Mannequin

myerscarpenter mannequin commented Apr 27, 2003

BPO 728515
Nosy @loewis, @birkenfeld, @birkenfeld, @facundobatista, @josiahcarlson
Files
  • mmap-resize-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 = 'https://github.com/birkenfeld'
    closed_at = <Date 2005-08-24.07:19:13.000>
    created_at = <Date 2003-04-27.17:44:53.000>
    labels = ['extension-modules']
    title = "mmap\\'s resize method resizes the file in win32 but not unix"
    updated_at = <Date 2005-08-24.07:19:13.000>
    user = 'https://bugs.python.org/myerscarpenter'

    bugs.python.org fields:

    activity = <Date 2005-08-24.07:19:13.000>
    actor = 'georg.brandl'
    assignee = 'georg.brandl'
    closed = True
    closed_date = None
    closer = None
    components = ['Extension Modules']
    creation = <Date 2003-04-27.17:44:53.000>
    creator = 'myers_carpenter'
    dependencies = []
    files = ['862']
    hgrepos = []
    issue_num = 728515
    keywords = []
    message_count = 9.0
    messages = ['15710', '15711', '15712', '15713', '15714', '15715', '15716', '15717', '15718']
    nosy_count = 6.0
    nosy_names = ['loewis', 'georg.brandl', 'georg.brandl', 'facundobatista', 'josiahcarlson', 'myers_carpenter']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue728515'
    versions = ['Python 2.4']

    @myerscarpenter
    Copy link
    Mannequin Author

    myerscarpenter mannequin commented Apr 27, 2003

    In the resize method under win32 you have something
    like this:

    /* Move to the desired EOF position \*/
        SetFilePointer (self-\>file_handle,
                new_size, NULL, FILE_BEGIN);
        /* Change the size of the file \*/
        SetEndOfFile (self-\>file_handle);
    

    Which resizes the file

    Under Unix you need to call

       ftruncate(self->fileno, new_size)

    before calling remap() to make it do the same thing.

    @myerscarpenter myerscarpenter mannequin closed this as completed Apr 27, 2003
    @myerscarpenter myerscarpenter mannequin added the extension-modules C modules in the Modules dir label Apr 27, 2003
    @myerscarpenter myerscarpenter mannequin closed this as completed Apr 27, 2003
    @myerscarpenter myerscarpenter mannequin added the extension-modules C modules in the Modules dir label Apr 27, 2003
    @loewis
    Copy link
    Mannequin

    loewis mannequin commented May 4, 2003

    Logged In: YES
    user_id=21627

    Would you like to contribute a patch? Please make sure to
    include changes to the documentation and test suite.

    @facundobatista
    Copy link
    Member

    Logged In: YES
    user_id=752496

    Please, could you verify if this problem persists in Python 2.3.4
    or 2.4?

    If yes, in which version? Can you provide a test case?

    If the problem is solved, from which version?

    Note that if you fail to answer in one month, I'll close this bug
    as "Won't fix".

    Thank you!

    . Facundo

    @facundobatista
    Copy link
    Member

    Logged In: YES
    user_id=752496

    Deprecated. Reopen only if still happens in 2.3 or newer.

    . Facundo

    @josiahcarlson
    Copy link
    Mannequin

    josiahcarlson mannequin commented May 30, 2005

    Logged In: YES
    user_id=341410

    The problem still persists in Python 2.3 and 2.4. A quick
    read of mmapmodule.c shows that ftruncate() is not being
    called within the non-windows portion of mmap_resize_method().

    @facundobatista
    Copy link
    Member

    Logged In: YES
    user_id=752496

    Reopened as posted that still is a bug.

    @birkenfeld
    Copy link
    Member

    Logged In: YES
    user_id=1188172

    This is not trivial since the filehandle can be closed at
    the time the ftruncate() would be necessary.

    The Windows specific code duplicates the filehandle upon
    mmap creation, perhaps the UNIX code should do this too?
    Then, the ftruncate call can be inserted.

    @birkenfeld
    Copy link
    Member

    Logged In: YES
    user_id=1188172

    Attaching patch which duplicates the file handle under UNIX
    too (btw, the size() method was broken too), mimics Windows
    behaviour with resize(), adds a testcase for this and
    clarifies the docs.

    @birkenfeld
    Copy link
    Member

    Logged In: YES
    user_id=1188172

    Okay, committed as
    Modules/mmapmodule.c; 2.50; 2.48.4.1
    Lib/test/test_mmap.py; 1.33; 1.30.18.1
    Doc/lib/libmmap.tex; 1.12; 1.9.4.2

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    extension-modules C modules in the Modules dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants