Fixes one mutex hang

When code invalidation is happening we currently have the issue that a
thread can acquire the code invalidation mutex in the middle of
invalidation. This is due to us acquiring and releasing the mutex
between each thread's code invalidation.

We need to hold the mutex for the entire duration for all thread's code
invalidation.
This fixes a rare hang on proton startup and resolves a consistent hang
on Proton application shutdown.

This now puts us on par with FEX-2312.1 with hanging.

This does not fix a relatively rare hang on fork (which also existed with FEX-2312.1).

This also does not fix the issue that the intersection of our mutexes
between frontend and backend are very convoluted. In part of the work
that is going to fix the rare fork mutex hang will change more of this.
This commit is contained in:
Ryan Houdek committed 2024-02-08 18:18:00 -08:00
1 parent 4331753ca0
commit 2480bab409
5 files changed
+19 -10

No files matched your search

+2
View File
@@ -7,6 +7,7 @@
#include <FEXCore/Utils/File.h>
#include <FEXCore/Utils/FileLoading.h>
#include <FEXCore/Utils/LogManager.h>
#include <FEXCore/Utils/SignalScopeGuards.h>
namespace CodeSize {
class CodeSizeValidation final {
@@ -199,6 +200,7 @@ namespace CodeSize {
ClearStats();
// Invalidate the code ranges to be safe.
auto CodeInvalidationlk = FEXCore::GuardSignalDeferringSection(CTX->GetCodeInvalidationMutex(), Thread);
CTX->InvalidateGuestCodeRange(Thread, (uint64_t)NOP, sizeof(NOP));
CTX->InvalidateGuestCodeRange(Thread, (uint64_t)MFENCE, sizeof(MFENCE));
SetupInfoDisabled = false;