Skip to content

Commit

Permalink
JIT Sparse Function Table random crash fix (#319)
Browse files Browse the repository at this point in the history
A couple of games have random crashing with the JIT Sparse Ftable changes, and it seems to have been caused by an insufficient int size returned by `AddressTableLevel#GetValue(ulong address)`.
It was 32 bits (Int32), but the GiantBlock (which is the current address table impl) uses potentially 36 bits for the first level.
  • Loading branch information
LotP1 authored and GreemDev committed Dec 19, 2024
1 parent b40cf69 commit b59b8ac
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/ARMeilleure/Common/AddressTableLevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public AddressTableLevel(int index, int length)
/// </summary>
/// <param name="address">Guest address</param>
/// <returns>Value of the <see cref="AddressTableLevel"/> from the specified guest <paramref name="address"/></returns>
public int GetValue(ulong address)
public long GetValue(ulong address)
{
return (int)((address & Mask) >> Index);
return (long)((address & Mask) >> Index);
}
}
}
2 changes: 1 addition & 1 deletion src/ARMeilleure/Translation/PTC/Ptc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Ptc : IPtcLoadState
private const string OuterHeaderMagicString = "PTCohd\0\0";
private const string InnerHeaderMagicString = "PTCihd\0\0";

private const uint InternalVersion = 6992; //! To be incremented manually for each change to the ARMeilleure project.
private const uint InternalVersion = 6997; //! To be incremented manually for each change to the ARMeilleure project.

private const string ActualDir = "0";
private const string BackupDir = "1";
Expand Down
2 changes: 1 addition & 1 deletion src/Ryujinx.Cpu/AddressTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public ref TEntry GetValue(ulong address)
{
TEntry* page = GetPage(address);

int index = Levels[^1].GetValue(address);
long index = Levels[^1].GetValue(address);

EnsureMapped((IntPtr)(page + index));

Expand Down

0 comments on commit b59b8ac

Please sign in to comment.