From 83bf62586e1647cd61687da2a23f6ada17a097e8 Mon Sep 17 00:00:00 2001 From: Gajo Petrovic Date: Tue, 11 Aug 2026 18:50:47 +0900 Subject: [PATCH 1/2] Windows: undefine the MemoryBarrier macro windows.h can define MemoryBarrier as a macro, colliding with the engine's Lua OpenGL MemoryBarrier symbol on Windows builds. --- rts/System/Platform/Win/win32.h | 1 + 1 file changed, 1 insertion(+) diff --git a/rts/System/Platform/Win/win32.h b/rts/System/Platform/Win/win32.h index 81bf95fdb31..57c61feb791 100644 --- a/rts/System/Platform/Win/win32.h +++ b/rts/System/Platform/Win/win32.h @@ -31,6 +31,7 @@ #undef DeleteFile #undef SendMessage #undef GetCharWidth + #undef MemoryBarrier #undef far #undef near #undef FAR From d128390d8982308e9b26b1abcdaa8d950d2f8533 Mon Sep 17 00:00:00 2001 From: Gajo Petrovic Date: Tue, 11 Aug 2026 19:16:55 +0900 Subject: [PATCH 2/2] unitsync: release Lua memory pool on shutdown --- test/unitsync/testUnitSync.cpp | 8 ++++++++ tools/unitsync/unitsync.cpp | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/test/unitsync/testUnitSync.cpp b/test/unitsync/testUnitSync.cpp index 338e31801b0..0aec702e3fe 100644 --- a/test/unitsync/testUnitSync.cpp +++ b/test/unitsync/testUnitSync.cpp @@ -350,4 +350,12 @@ TEST_CASE("UnitSync") if ((errmsg = us::GetNextError()) == nullptr) { FAIL_CHECK("No error on GetWritableDataDirectory before init"); // there's an error cause we called GetWritableDataDirectory() after UnInit()! } + + // Exercise repeated initialization and shutdown. + for (int cycle = 0; cycle < 2; ++cycle) { + CHECK(us::Init(false, 0) != 0); + CHECK_ERROR_MESSAGE(errmsg); + us::UnInit(); + CHECK_ERROR_MESSAGE(errmsg); + } } diff --git a/tools/unitsync/unitsync.cpp b/tools/unitsync/unitsync.cpp index 7da1def5408..5140328b99c 100644 --- a/tools/unitsync/unitsync.cpp +++ b/tools/unitsync/unitsync.cpp @@ -12,6 +12,7 @@ // shared with spring: #include "lib/lua/include/LuaInclude.h" #include "Game/GameVersion.h" +#include "Lua/LuaMemPool.h" #include "Lua/LuaParser.h" #include "Map/MapParser.h" #include "Map/ReadMap.h" @@ -421,6 +422,7 @@ EXPORT(void) UnInit() try { _Cleanup(); FileSystemInitializer::Cleanup(); + LuaMemPool::KillStatic(); ConfigHandler::Deallocate(); DataDirLocater::FreeInstance(); } @@ -2371,4 +2373,3 @@ EXPORT(const char*) GetMacAddrHash() { memcpy(macAddrBuf.data(), macAddrHash.data(), std::min(macAddrHash.size(), macAddrBuf.size())); return (macAddrBuf.data()); } -