[iostreams] mapped_file trouble

Hi, I just wanted to point out a fairly major flaw with the Windows implementation of memory mapped files. In memory_mapped.cpp on line 205-207 a file mapping is created as follows: ::CreateFileMappingA( pimpl_->handle_, NULL, readonly ? PAGE_READONLY : PAGE_READWRITE, 0, 0, p.path.c_str() ); The problem with this is that if p.path.c_str() has any backslashes in it (very likely given that it's Windows), the call fails. From the MS documentation: "Windows NT: The name can contain any character except the backslash character. Windows Me/98/95: The name can contain any character except the backslash character. The empty string ("") is a valid object name." Also from the documentation: "If this parameter is NULL, the mapping object is created without a name." Given that there's no way to access named memory maps from the boost interface anyway, it seems pointless to name the mapping. My suggestion is to pass in NULL and avoid naming difficulties altogether. Thanks, Dylan Trotter

Pardon me, correction: Dylan Trotter wrote:
Hi,
I just wanted to point out a fairly major flaw with the Windows implementation of memory mapped files. In memory_mapped.cpp on line
*mapped_file.cpp*, not memory_mapped.cpp
205-207 a file mapping is created as follows:
::CreateFileMappingA( pimpl_->handle_, NULL, readonly ? PAGE_READONLY : PAGE_READWRITE, 0, 0, p.path.c_str() );
The problem with this is that if p.path.c_str() has any backslashes in it (very likely given that it's Windows), the call fails. From the MS documentation:
"Windows NT: The name can contain any character except the backslash character. Windows Me/98/95: The name can contain any character except the backslash character. The empty string ("") is a valid object name."
Also from the documentation:
"If this parameter is NULL, the mapping object is created without a name."
Given that there's no way to access named memory maps from the boost interface anyway, it seems pointless to name the mapping. My suggestion is to pass in NULL and avoid naming difficulties altogether.
Thanks,
Dylan Trotter
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Dylan Trotter wrote:
Hi,
I just wanted to point out a fairly major flaw with the Windows implementation of memory mapped files. In memory_mapped.cpp on line 205-207 a file mapping is created as follows:
::CreateFileMappingA( pimpl_->handle_, NULL, readonly ? PAGE_READONLY : PAGE_READWRITE, 0, 0, p.path.c_str() );
The problem with this is that if p.path.c_str() has any backslashes in it (very likely given that it's Windows), the call fails. From the MS documentation:
Thanks. I thought I eliminated the name a long time ago; I'll fix it in the patch I'm preparing right now (and add you to the acknowledgments).
Thanks,
Dylan Trotter
Jonathan
participants (2)
-
Dylan Trotter
-
Jonathan Turkanis