Skip to content

Commit ea8b4c8

Browse files
committed
[Windows] Fix x64 platform view init race condition
This mirrors the fix that was performed on the x86 platform
1 parent 27f966a commit ea8b4c8

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

platform/windows/platform_windows.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class WindowsX64Platform: public Platform
9292
{
9393
uint32_t m_gsbase;
9494
Ref<Type> m_teb;
95+
std::mutex m_tebMutex;
9596

9697
public:
9798
WindowsX64Platform(Architecture* arch): Platform(arch, "windows-x86_64")
@@ -113,6 +114,8 @@ class WindowsX64Platform: public Platform
113114

114115
virtual void BinaryViewInit(BinaryView* view) override
115116
{
117+
// Locking here so that if we have two views in BinaryViewInit at once we don't race to init m_teb.
118+
std::lock_guard<std::mutex> lock(m_tebMutex);
116119
if (!m_teb)
117120
m_teb = Type::PointerType(GetArchitecture()->GetAddressSize(), Type::NamedType(QualifiedName("TEB"), GetTypeByName(QualifiedName("TEB"))));
118121
}

0 commit comments

Comments
 (0)