mirror of https://github.com/PCSX2/pcsx2.git
pcsx2: Fix a few crashes in macOS. (#3424)
* Fix crash on shutdown in macOS * Fix crashing in ISO list on macOS * Use MAP_FIXED on linux too It works as expected and has no race conditions.
This commit is contained in:
parent
c23f3be21f
commit
f7d84c4637
|
@ -178,21 +178,12 @@ bool HostSys::MmapCommitPtr(void *base, size_t size, const PageProtectionMode &m
|
||||||
|
|
||||||
void HostSys::MmapResetPtr(void *base, size_t size)
|
void HostSys::MmapResetPtr(void *base, size_t size)
|
||||||
{
|
{
|
||||||
// On linux the only way to reset the memory is to unmap and remap it as PROT_NONE.
|
PageSizeAssertionTest(size);
|
||||||
// That forces linux to unload all committed pages and start from scratch.
|
|
||||||
|
|
||||||
// FIXME: Ideally this code would have some threading lock on it to prevent any other
|
void *result = mmap(base, size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
|
||||||
// malloc/free code in the current process from interfering with the operation, but I
|
|
||||||
// can't think of any good way to do that. (generally it shouldn't be a problem in
|
|
||||||
// PCSX2 anyway, since MmapReset is only called when the ps2vm is suspended; so that
|
|
||||||
// pretty well stops all PCSX2 threads anyway).
|
|
||||||
|
|
||||||
Munmap(base, size);
|
|
||||||
void *result = MmapReservePtr(base, size);
|
|
||||||
|
|
||||||
pxAssertRel((uptr)result == (uptr)base, pxsFmt(
|
pxAssertRel((uptr)result == (uptr)base, pxsFmt(
|
||||||
"Virtual memory decommit failed: memory at 0x%08X -> 0x%08X could not be remapped. "
|
"Virtual memory decommit failed: memory at 0x%08X -> 0x%08X could not be remapped.",
|
||||||
"This is likely caused by multi-thread memory contention.",
|
|
||||||
base, (uptr)base + size));
|
base, (uptr)base + size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,9 @@ void RecentIsoManager::RemoveAllFromMenu()
|
||||||
if( m_Menu == NULL ) return;
|
if( m_Menu == NULL ) return;
|
||||||
|
|
||||||
int cnt = m_Items.size();
|
int cnt = m_Items.size();
|
||||||
for( int i=0; i<cnt; ++i )
|
// Note: Go backwards to work around https://trac.wxwidgets.org/ticket/18772
|
||||||
|
// Switch it back to forwards once that's fixed in a relased WX version
|
||||||
|
for( int i=cnt-1; i>=0; --i )
|
||||||
{
|
{
|
||||||
RecentItem& curitem( m_Items[i] );
|
RecentItem& curitem( m_Items[i] );
|
||||||
if( curitem.ItemPtr == NULL ) continue;
|
if( curitem.ItemPtr == NULL ) continue;
|
||||||
|
|
Loading…
Reference in New Issue