Subject: Re: [Boost-bugs] [Boost C++ Libraries] #699: Changing size of memory-mapped file on Windows
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2007-08-19 15:55:53
#699: Changing size of memory-mapped file on Windows
---------------------+------------------------------------------------------
Reporter: nobody | Owner: turkanis
Type: Bugs | Status: assigned
Milestone: | Component: iostreams
Version: None | Severity: Problem
Resolution: None | Keywords:
---------------------+------------------------------------------------------
Changes (by marshall):
* component: None => iostreams
* severity: => Problem
Old description:
> {{{
> My email address is barrywhart_at_yahoo.com.
>
> There is a bug in
> mapped_file_source::open_impl(mapped_file_params p)
>
> This function does not correctly check for errors from
> SetFilePointer, as documented in the MSDN page below.
> (See "Case Two: calling the function with
> lpDistanceToMoveHigh != NULL")
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-
> us/fileio/fs/setfilepointer.asp
>
> Current code:
>
> ::SetFilePointer(pimpl_->handle_, sizelow,
> &sizehigh, FILE_BEGIN);
> if (::GetLastError() != NO_ERROR ||
> !::SetEndOfFile(pimpl_->handle_))
> detail::cleanup_and_throw(*pimpl_, "failed
> setting file size");
>
> Should be:
>
> DWORD dwResult =
> ::SetFilePointer(pimpl_->handle_, sizelow, &sizehigh,
> FILE_BEGIN);
> if (dwResult == INVALID_SET_FILE_POINTER
> ::GetLastError() != NO_ERROR ||
> !::SetEndOfFile(pimpl_->handle_))
> detail::cleanup_and_throw(*pimpl_, "failed
> setting file size");
>
> --
>
> Even after this fix, the ability to resize an existing
> file is not really useful because the file is
> apparently recreated rather than resized. I am working
> around this by resizing the file using system calls,
> but I wonder if this is how the function is supposed to
> work?!
> }}}
New description:
{{{
My email address is barrywhart_at_yahoo.com.
There is a bug in
mapped_file_source::open_impl(mapped_file_params p)
This function does not correctly check for errors from
SetFilePointer, as documented in the MSDN page below.
(See "Case Two: calling the function with
lpDistanceToMoveHigh != NULL")
http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/fileio/fs/setfilepointer.asp
Current code:
::SetFilePointer(pimpl_->handle_, sizelow,
&sizehigh, FILE_BEGIN);
if (::GetLastError() != NO_ERROR ||
!::SetEndOfFile(pimpl_->handle_))
detail::cleanup_and_throw(*pimpl_, "failed
setting file size");
Should be:
DWORD dwResult =
::SetFilePointer(pimpl_->handle_, sizelow, &sizehigh,
FILE_BEGIN);
if (dwResult == INVALID_SET_FILE_POINTER
::GetLastError() != NO_ERROR ||
!::SetEndOfFile(pimpl_->handle_))
detail::cleanup_and_throw(*pimpl_, "failed
setting file size");
--
Even after this fix, the ability to resize an existing
file is not really useful because the file is
apparently recreated rather than resized. I am working
around this by resizing the file using system calls,
but I wonder if this is how the function is supposed to
work?!
}}}
--
Ticket URL: <http://svn.boost.org/trac/boost/ticket/699#comment:1>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:56 UTC