Boost C++ Libraries: Ticket #3572: mapped_file: reading/writing mapped memory can throw (structured) exceptions? (windows) https://svn.boost.org/trac10/ticket/3572 <p> msdn: "Reading and Writing From a File View" (<a class="ext-link" href="http://msdn.microsoft.com/en-us/library/aa366801(VS.85).aspx"><span class="icon">​</span>http://msdn.microsoft.com/en-us/library/aa366801(VS.85).aspx</a>) </p> <p> "Reading from or writing to a file view can cause an EXCEPTION_IN_PAGE_ERROR exception. For example, accessing a mapped file that resides on a remote server can generate an exception if the connection to the server is lost. Exceptions can also occur because of a full disk, an underlying device failure, or a memory allocation failure. When writing to a file view, exceptions can also occur because the file is shared and a different process has locked a byte range. To guard against exceptions due to input and output (I/O) errors, all attempts to access memory mapped files should be wrapped in structured exception handlers" </p> <blockquote> <p> DWORD dwLength; <span class="underline">try { </span></p> <blockquote> <p> dwLength = *((LPDWORD) lpMapAddress); </p> </blockquote> <p> } <span class="underline">except(<a class="missing wiki">GetExceptionCode</a>()==EXCEPTION_IN_PAGE_ERROR ? </span></p> <blockquote> <p> EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) </p> </blockquote> <p> { </p> <blockquote> <p> <em> Failed to read from the view. </em></p> </blockquote> <p> } </p> </blockquote> <p> ... so it should be mentioned in the documentation? (windows specific) </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3572 Trac 1.4.3 anonymous Wed, 28 Oct 2009 12:15:26 GMT <link>https://svn.boost.org/trac10/ticket/3572#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3572#comment:1</guid> <description> <p> interesting: </p> <p> <a class="ext-link" href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6415680"><span class="icon">​</span>http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6415680</a> </p> <p> java has a get method, to access bytes in a <a class="missing wiki">FileChannel</a> (=mmap'ed file), which should do the checking ... </p> </description> <category>Ticket</category> </item> </channel> </rss>