Skip to content

Commit eef303f

Browse files
authored
Merge pull request #6033 from Sonicadvance1/271
DiskCache: Fixes a race condition on the data blob
2 parents fb925d6 + b49837f commit eef303f

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

‎FEXCore/Source/Interface/Core/DiskCache.cpp‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,9 +1026,8 @@ namespace DiskCache {
10261026
const size_t TotalSize = GuestCodeOffset + GuestCode.size();
10271027

10281028
// we'll copy everything into here and pass it to the Writer, then return to caller quickly
1029-
fextl::vector<uint8_t> Blob;
1030-
Blob.resize(TotalSize);
1031-
uint8_t* BlobData = Blob.data();
1029+
auto BlobRef = fextl::make_shared<fextl::vector<uint8_t>>(TotalSize);
1030+
uint8_t* BlobData = BlobRef->data();
10321031

10331032
BlobFixedHeader Header {
10341033
.GuestSize = (uint32_t)GuestCode.size(),
@@ -1182,7 +1181,6 @@ namespace DiskCache {
11821181
MakeLookupKey(Thread, GuestCodeKey, RangeInfo.Writable, GuestRIP == CTX->GetMonoBackPatcherBlock().load(std::memory_order_relaxed));
11831182

11841183
// blob done, publish to index as in-memory for now, flush to disk below
1185-
auto BlobRef = fextl::make_shared<fextl::vector<uint8_t>>(std::move(Blob));
11861184
struct IndexEntry NewEntry {nullptr, 0, (uint32_t)TotalSize, Header.GuestSize, Header.GuestHash, BlobRef};
11871185
NewEntry.GuestExtents = ExactGuestCodeExtents;
11881186
{

0 commit comments

Comments
 (0)