dolphin/Source/Core/Common
JosJuice 989bdb8d6d Common/CodeBlock: Call ResetCodePtr when decreasing region_size
Fixes https://bugs.dolphin-emu.org/issues/12827.

A description of what was going wrong:

JitArm64::Init first calls CodeBlock::AllocCodeSpace, after which
CodeBlock and Arm64Emitter consider us to have 96 MB of code space
available. JitArm64::Init then calls AddChildCodeSpace, which is
supposed to take 64 MiB of that space and give it to m_far_code.
CodeBlock's view of how much space there is gets updated from 96 MiB
to 32 MiB, but due to the missing call, Arm64Emitter keeps thinking
that it has 96 MiB of space available.

The last thing JitArm64::Init does is to call ResetFreeMemoryRanges.
This function asks Arm64Emitter how much code space is available and
stores a range of that size in m_free_ranges_near, meaning that
m_free_ranges_near ends up being backed by both nearcode and farcode!
This is a ticking time bomb; as soon as we grab memory from
m_free_ranges_near which is backed by farcode, we're in trouble.
The crash I ran into in my testing was caused by fastmem code being
allocated in farcode (our backpatch handler only handles accesses made
from nearcode), but you may as well get errors caused by code intended
for nearcode overwriting code intended for farcode or vice versa.

So why did NBA Live 2005 crash when most games had no problems,
and why was the bug bisected to the commit that increased the size
of far code from 16 MiB to 64 MiB? Well, as long as we're only
using the first 32 MiB of the big 96 MiB range, everything works.
What happens with NBA Live 2005 (I have not investigated exactly
through what mechanism this happens) is that at some point the range
in m_free_ranges_near gets split into two ranges, one which is
backed by nearcode and one which is backed by farcode. Dolphin
prefers to select the biggest range available (we don't want to
pick a tiny 1 KiB range that may not be able to fit the whole block
we're about to emit, after all), and after increasing the size of
farcode to 64 MiB, farcode is bigger than nearcode.
2022-02-12 17:51:32 +01:00
..
Config Config: Allow unregistering callbacks. 2021-12-25 23:32:49 +01:00
Crypto Treewide: Adjust order of includes 2021-12-10 14:49:57 -08:00
Debug treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
GL Treewide: Adjust order of includes 2021-12-10 14:49:57 -08:00
Logging Use Common::ToLower and Common::ToUpper 2022-01-16 17:00:12 -08:00
Align.h licensing: convert "public domain" to CC0 1.0 2021-07-05 04:43:55 +02:00
Analytics.cpp Treewide: Adjust order of includes 2021-12-10 14:49:57 -08:00
Analytics.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
AndroidAnalytics.cpp Android: Mark s_android_send_report as static 2022-01-06 12:20:09 +01:00
AndroidAnalytics.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
Arm64Emitter.cpp Cast to int for enums that are not formattable 2022-01-13 11:11:08 -08:00
Arm64Emitter.h Merge pull request #10055 from JosJuice/jitarm64-reuse-memory 2021-11-20 17:35:24 -05:00
ArmCPUDetect.cpp Treewide: Adjust order of includes 2021-12-10 14:49:57 -08:00
ArmCommon.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
ArmFPURoundMode.cpp Treewide: Adjust order of includes 2021-12-10 14:49:57 -08:00
Assert.h Common/Assert: Actually use the ASSERT_MSG's log type parameter 2022-01-09 12:44:14 -08:00
BitField.h Make all custom fmt::formatter's format functions const 2022-01-13 11:11:08 -08:00
BitField.natvis Improve BitField natvis 2022-01-02 14:39:34 -08:00
BitSet.h remove an outdated comment 2021-07-17 17:46:57 -07:00
BitUtils.h JitArm64: Turn IsImmLogical into a constexpr constructor 2021-07-10 20:31:28 +02:00
BlockingLoop.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
CDUtils.cpp Treewide: Adjust order of includes 2021-12-10 14:49:57 -08:00
CDUtils.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
CMakeLists.txt Common: Create HRWrap 2022-01-09 12:44:15 -08:00
CPUDetect.h Fix CPU Core Count detection and Enable Parallel Shader Compilation 2021-11-20 16:08:10 +01:00
ChunkFile.h Common/Assert: Switch to fmt 2022-01-09 12:43:11 -08:00
CodeBlock.h Common/CodeBlock: Call ResetCodePtr when decreasing region_size 2022-02-12 17:51:32 +01:00
ColorUtil.cpp treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
ColorUtil.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
Common.h Common/MsgHandler: Remove non-format variants of PanicAlert 2022-01-09 12:44:14 -08:00
CommonFuncs.cpp Treewide: Adjust order of includes 2021-12-10 14:49:57 -08:00
CommonFuncs.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
CommonPaths.h CommonPaths: Add a Riivolution subfolder in Load. 2021-10-24 00:09:06 +02:00
CommonTypes.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
CompatPatches.cpp Add fmt/xchar includes where wstring is used 2022-01-13 11:11:08 -08:00
DebugInterface.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
DynamicLibrary.cpp treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
DynamicLibrary.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
ENetUtil.cpp Treewide: Adjust order of includes 2021-12-10 14:49:57 -08:00
ENetUtil.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
EnumFormatter.h Merge pull request #10367 from Pokechu22/fmt-8.1.1 2022-01-20 21:14:41 +01:00
EnumMap.h Create EnumMap 2021-10-24 11:48:36 -07:00
EnumMap.natvis Create EnumMap natvis 2022-01-02 15:36:47 -08:00
Event.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
FPURoundMode.h remove SetRoundMode 2021-07-17 19:29:22 -07:00
FileSearch.cpp Treewide: Adjust order of includes 2021-12-10 14:49:57 -08:00
FileSearch.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
FileUtil.cpp Core: Make format of D_WIIROOT_IDX consistent with the rest of the user directories. 2021-12-25 20:21:32 +01:00
FileUtil.h Common/FileUtil: Ensure consistency for custom user paths. 2021-12-25 20:21:32 +01:00
FixedSizeQueue.h Fix all uninitialized variable warnings (C26495) 2021-10-13 12:32:16 -07:00
Flag.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
FloatUtils.cpp treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
FloatUtils.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
FormatUtil.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
GekkoDisassembler.cpp treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
GekkoDisassembler.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
GenericCPUDetect.cpp treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
GenericFPURoundMode.cpp Treewide: Adjust order of includes 2021-12-10 14:49:57 -08:00
HRWrap.cpp Common: Create HRWrap 2022-01-09 12:44:15 -08:00
HRWrap.h Make all custom fmt::formatter's format functions const 2022-01-13 11:11:08 -08:00
Hash.cpp Replace remaining uses of zlib crc32 with Common/Hash.h 2022-01-01 10:36:38 -08:00
Hash.h Replace remaining uses of zlib crc32 with Common/Hash.h 2022-01-01 10:36:38 -08:00
HttpRequest.cpp Replace use of of unsigned char* with fmt 2022-01-13 11:11:08 -08:00
HttpRequest.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
IOFile.cpp IOFile: Rename Clear() to ClearError() for clarity. 2022-01-29 06:49:22 +01:00
IOFile.h IOFile: Rename Clear() to ClearError() for clarity. 2022-01-29 06:49:22 +01:00
Image.cpp Cast to int for enums that are not formattable 2022-01-13 11:11:08 -08:00
Image.h Add option for setting the PNG zlib compression level 2021-11-18 13:10:22 -08:00
ImageC.c Fix saving RGBA images 2021-11-24 14:56:12 -08:00
ImageC.h Fix saving RGBA images 2021-11-24 14:56:12 -08:00
IniFile.cpp treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
IniFile.h Use Common::ToLower and Common::ToUpper 2022-01-16 17:00:12 -08:00
Inline.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
Intrinsics.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
JitRegister.cpp treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
JitRegister.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
Lazy.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
LdrWatcher.cpp Treewide: Adjust order of includes 2021-12-10 14:49:57 -08:00
LdrWatcher.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
LinearDiskCache.h IOFile: Rename Clear() to ClearError() for clarity. 2022-01-29 06:49:22 +01:00
MathUtil.cpp treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
MathUtil.h MathUtil: Mark IntLog2 as constexpr 2021-07-06 15:01:38 +02:00
Matrix.cpp Treewide: Adjust order of includes 2021-12-10 14:49:57 -08:00
Matrix.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
MemArena.h MemArena: Use placeholders on Windows. 2022-02-06 18:06:04 +01:00
MemArenaAndroid.cpp MemArena: Prepare interface for proper memory reservation. 2021-12-25 20:20:36 +01:00
MemArenaUnix.cpp MemArena: Prepare interface for proper memory reservation. 2021-12-25 20:20:36 +01:00
MemArenaWin.cpp MemArena: Use placeholders on Windows. 2022-02-06 18:06:04 +01:00
MemoryUtil.cpp Treewide: Adjust order of includes 2021-12-10 14:49:57 -08:00
MemoryUtil.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
MinizipUtil.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
MsgHandler.cpp Common/MsgHandler: Use caller's file and line number in log messages 2022-01-09 12:44:14 -08:00
MsgHandler.h Use fmt::runtime in FmtFormatT 2022-01-13 11:11:08 -08:00
NandPaths.cpp Core: Make format of D_WIIROOT_IDX consistent with the rest of the user directories. 2021-12-25 20:21:32 +01:00
NandPaths.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
Network.cpp Use Common::ToLower and Common::ToUpper 2022-01-16 17:00:12 -08:00
Network.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
PcapFile.cpp Treewide: Adjust order of includes 2021-12-10 14:49:57 -08:00
PcapFile.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
PerformanceCounter.cpp Treewide: Adjust order of includes 2021-12-10 14:49:57 -08:00
PerformanceCounter.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
Profiler.cpp Treewide: Adjust order of includes 2021-12-10 14:49:57 -08:00
Profiler.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
QoSSession.cpp Treewide: Adjust order of includes 2021-12-10 14:49:57 -08:00
QoSSession.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
Random.cpp treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
Random.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
Result.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
SCMRevGen.vcxproj msvc: update to vs2022 and windows sdk 10.0.22000 2021-11-11 08:01:26 -08:00
SDCardUtil.cpp msvc: remove warning disables which no longer fire 2021-07-17 18:24:36 -07:00
SDCardUtil.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
SFMLHelper.cpp treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
SFMLHelper.h SFMLHelper: Add stream insertion overload helpers for enum types 2021-09-22 15:42:01 -04:00
SPSCQueue.h Fix all uninitialized variable warnings (C26495) 2021-10-13 12:32:16 -07:00
ScopeGuard.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
Semaphore.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
SettingsHandler.cpp Use fmt::localtime instead of thread-unsafe std::localtime 2021-10-15 22:49:13 +02:00
SettingsHandler.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
SocketContext.cpp treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
SocketContext.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
StringUtil.cpp Create Common::ToLower and Common::ToUpper 2022-01-16 16:56:53 -08:00
StringUtil.h Create Common::ToLower and Common::ToUpper 2022-01-16 16:56:53 -08:00
Swap.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
SymbolDB.cpp Treewide: Adjust order of includes 2021-12-10 14:49:57 -08:00
SymbolDB.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
Thread.cpp Treewide: Adjust order of includes 2021-12-10 14:49:57 -08:00
Thread.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
Timer.cpp treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
Timer.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
TraversalClient.cpp Cast to int for enums that are not formattable 2022-01-13 11:11:08 -08:00
TraversalClient.h licensing: convert "public domain" to CC0 1.0 2021-07-05 04:43:55 +02:00
TraversalProto.h licensing: convert "public domain" to CC0 1.0 2021-07-05 04:43:55 +02:00
TraversalServer.cpp licensing: convert "public domain" to CC0 1.0 2021-07-05 04:43:55 +02:00
TypeUtils.h Create EnumMap 2021-10-24 11:48:36 -07:00
UPnP.cpp Merge pull request #9709 from AdmiralCurtiss/upnp-error-log 2021-07-06 15:36:38 +02:00
UPnP.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
VariantUtil.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
Version.cpp Fix static initialisation order fiasco issue for Version variables 2022-01-14 00:04:22 +01:00
Version.h Fix static initialisation order fiasco issue for Version variables 2022-01-14 00:04:22 +01:00
WindowSystemInfo.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
WorkQueueThread.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
make_scmrev.h.js make_scmrev.h.js: set default auto-update track from environment 2018-03-19 00:11:55 +01:00
scmrev.h.in Make it possible to enable auto-updates by default with CMake builds 2021-04-17 19:45:43 +02:00
x64ABI.cpp Treewide: Adjust order of includes 2021-12-10 14:49:57 -08:00
x64ABI.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
x64CPUDetect.cpp Merge pull request #9414 from DevJPM/master 2022-01-04 10:15:12 -05:00
x64Emitter.cpp Common/Assert: Switch to fmt 2022-01-09 12:43:11 -08:00
x64Emitter.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00
x64FPURoundMode.cpp Treewide: Adjust order of includes 2021-12-10 14:49:57 -08:00
x64Reg.h treewide: convert GPLv2+ license info to SPDX tags 2021-07-05 04:35:56 +02:00