[hxcommon] CR: prevent player crash when playing corrupted content from the CD
Henry Ping ping at real.comAttached is the diff submitted by Jeff Leitner with the following comment:
"
There is a mpeg clip on the cd Ozzy_Osbourne-Shot_In_The_Dark.mpg which
appears to have some unreadable bytes towards the end of the file possibly
because a portion of the disc is bad. What happens is when the player
attempts to get the durations for all the tracks it crashes in the mpeg
file format. The problem is not in the mpeg file format, but in the memory
mapped memory manager that simple file system uses. When MapViewOfFile is
called it returns a handle to a page of memory that the system no longer
knows about so an exception occurs. It is usally a EXCEPTION_IN_PAGE_ERROR.
Reading the documentation it appears that all access to handles returned
from memory mapped I/O should be wrapped in try/catch blocks since the
handles may be invalid. I added try/catch logic to test this out and it
fixes the bug. The main problem I'm not sure about is that this code is
also used by the server and IsBadReadPtr may iterate over the memory block
which can be slow. Because this is the layer of code that "knows" it is
using memory mapped I/O this is probably where the try/catch code belongs
so that if an exception occurs then it can return an error and no buffer
since the buffer wouldn't be accessible anyway. Maybe you can think of a
better way to test if the memory handle is valid such as checking
first/last byte of the range if that works. I also had to enable exception
handling in the win.pcf file.
"
I'll check this in by EOD if no objections.
-->Henry
-------------- next part --------------
? common_fileio.dsp
? common_fileio.dsw
? dbg32
? Umakefil.upp
? Makefile
? a
Index: mmapmgr.cpp
===================================================================
RCS file: /cvs/common/fileio/mmapmgr.cpp,v
retrieving revision 1.5
diff -u -w -4 -r1.5 mmapmgr.cpp
--- mmapmgr.cpp 20 Feb 2003 15:14:08 -0000 1.5
+++ mmapmgr.cpp 7 Jul 2003 21:06:24 -0000
@@ -711,15 +711,42 @@
pEntry->pPage = MAP_FAIL;
}
else
{
+#if !defined(HELIX_FEATURE_SERVER) && defined(_WINDOWS)
+ BOOL bInvalid = TRUE;
+
+ try
+ {
+ bInvalid = ::IsBadReadPtr(pEntry->pPage, ulChunkSize);
+ }
+ catch (...)
+ {
+ }
+
+ if (bInvalid)
+ {
+ pEntry->pPage = MAP_FAIL;
+ }
+ else
+ {
+ if (pInfo->m_pPTEList)
+ {
+ pInfo->m_pPTEList->m_pPrevPTE = pEntry;
+ }
+ pEntry->m_pNextPTE = pInfo->m_pPTEList;
+ pEntry->m_pPrevPTE = NULL;
+ pInfo->m_pPTEList = pEntry;
+ }
+#else
if (pInfo->m_pPTEList)
{
pInfo->m_pPTEList->m_pPrevPTE = pEntry;
}
pEntry->m_pNextPTE = pInfo->m_pPTEList;
pEntry->m_pPrevPTE = NULL;
pInfo->m_pPTEList = pEntry;
+#endif /* !HELIX_FEATURE_SERVER && _WINDOWS */
}
#endif
#endif /* _BEOS */
Index: win.pcf
===================================================================
RCS file: /cvs/common/fileio/win.pcf,v
retrieving revision 1.4
diff -u -w -4 -r1.4 win.pcf
--- win.pcf 13 Dec 2002 02:46:15 -0000 1.4
+++ win.pcf 7 Jul 2003 21:06:24 -0000
@@ -50,4 +50,6 @@
'platform/win/winff.cpp',
'platform/win/winfile.cpp',
'platform/win/filespec.cpp',
'platform/win/filespecutils.cpp')
+
+cc.args['default'] = string.replace(cc.args['default'], '/GX-', '/GX')
-------------- next part --------------
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe at common.helixcommunity.org
For additional commands, e-mail: dev-help at common.helixcommunity.org