upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/test/xmem_test.cpp
diff options
context:
space:
mode:
authorJan Trencansky <jan.trencansky@protonmail.com>2026-11-26 10:05:43 -0500
committerJan Trencansky <jan.trencansky@protonmail.com>2026-11-26 10:05:43 -0500
commit4a6a8a633e71ceb5af7afbaadcf9ad2e4ba9a377 (patch)
tree711e71b9a2c47b22c2775d152380c3df48c1a9c3 /runtime/test/xmem_test.cpp
parent1f7cbeff9a0461c037287e83297e9add75d2646a (diff)
xmem: read LEONIDA_GEOMETRY_REMAP_RELEASE once, with a test seam to read it again
GetEnvironmentVariableA at every remap ran under g_phys_mutex in every scatter call; with it, xmem_test's split race ("the reader of the views' last pages never faults or misreads") failed in two full Wine runs in a row, where main passed it twice. The value is cached as before #2350's default changed; rt::xmem::reload_remap_release_setting lets test_remap_releases switch it. Two full runs since: no change against main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/test/xmem_test.cpp')
-rw-r--r--runtime/test/xmem_test.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/runtime/test/xmem_test.cpp b/runtime/test/xmem_test.cpp
index 61e8732e1..d5e866a76 100644
--- a/runtime/test/xmem_test.cpp
+++ b/runtime/test/xmem_test.cpp
@@ -469,16 +469,19 @@ void test_remap_releases(const PhysicalApi& api) {
469 char previous[8]{}; 469 char previous[8]{};
470 const DWORD had = GetEnvironmentVariableA("LEONIDA_GEOMETRY_REMAP_RELEASE", previous, sizeof(previous)); 470 const DWORD had = GetEnvironmentVariableA("LEONIDA_GEOMETRY_REMAP_RELEASE", previous, sizeof(previous));
471 SetEnvironmentVariableA("LEONIDA_GEOMETRY_REMAP_RELEASE", nullptr); 471 SetEnvironmentVariableA("LEONIDA_GEOMETRY_REMAP_RELEASE", nullptr);
472 rt::xmem::reload_remap_release_setting();
472 const uint64_t first[kPages] = {pages[0], pages[1], pages[2]}; 473 const uint64_t first[kPages] = {pages[0], pages[1], pages[2]};
473 const uint64_t other[kPages] = {pages[3], pages[2], pages[1]}; 474 const uint64_t other[kPages] = {pages[3], pages[2], pages[1]};
474 check(api.map(window, kPages, first) == window && api.map(window, kPages, other) == window && take().empty(), 475 check(api.map(window, kPages, first) == window && api.map(window, kPages, other) == window && take().empty(),
475 "remap releases: off by default, a remap releases nothing"); 476 "remap releases: off by default, a remap releases nothing");
476 SetEnvironmentVariableA("LEONIDA_GEOMETRY_REMAP_RELEASE", "0"); 477 SetEnvironmentVariableA("LEONIDA_GEOMETRY_REMAP_RELEASE", "0");
478 rt::xmem::reload_remap_release_setting();
477 check(api.map(window, kPages, first) == window && take().empty(), 479 check(api.map(window, kPages, first) == window && take().empty(),
478 "remap releases: LEONIDA_GEOMETRY_REMAP_RELEASE=0 releases nothing"); 480 "remap releases: LEONIDA_GEOMETRY_REMAP_RELEASE=0 releases nothing");
479 check(api.map(window, kPages, nullptr) == window && !take().empty() && covers(base, base + 3 * kPage64k), 481 check(api.map(window, kPages, nullptr) == window && !take().empty() && covers(base, base + 3 * kPage64k),
480 "remap releases: unmapping releases the range whatever the setting"); 482 "remap releases: unmapping releases the range whatever the setting");
481 SetEnvironmentVariableA("LEONIDA_GEOMETRY_REMAP_RELEASE", "1"); 483 SetEnvironmentVariableA("LEONIDA_GEOMETRY_REMAP_RELEASE", "1");
484 rt::xmem::reload_remap_release_setting();
482 485
483 check(api.map(window, kPages, first) == window && take().empty(), 486 check(api.map(window, kPages, first) == window && take().empty(),
484 "remap releases: a first mapping of unmapped pages releases nothing"); 487 "remap releases: a first mapping of unmapped pages releases nothing");
@@ -513,6 +516,7 @@ void test_remap_releases(const PhysicalApi& api) {
513 "remap releases: unmapping releases the range"); 516 "remap releases: unmapping releases the range");
514 SetEnvironmentVariableA("LEONIDA_GEOMETRY_REMAP_RELEASE", 517 SetEnvironmentVariableA("LEONIDA_GEOMETRY_REMAP_RELEASE",
515 had > 0 && had < sizeof(previous) ? previous : nullptr); 518 had > 0 && had < sizeof(previous) ? previous : nullptr);
519 rt::xmem::reload_remap_release_setting();
516 for (uint64_t i = 0; i < kPages; ++i) watch::release(base + i * kPage64k); 520 for (uint64_t i = 0; i < kPages; ++i) watch::release(base + i * kPage64k);
517 watch::unsubscribe(queue); 521 watch::unsubscribe(queue);
518 api.free_pages(4, pages); 522 api.free_pages(4, pages);