Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b852d21a54 |
No files matched your search
@@ -28,6 +28,15 @@ numeric core and does not move; the heading is the full version — corrected 20
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
|
||||
- **The native ring-buffer tests no longer pass or fail by the scheduler's luck** (developers only). The
|
||||
hammering-writer test required the reader to keep more than half of the stream, which measured how the operating
|
||||
system scheduled two threads: on a hybrid Intel processor it failed 5 of 200 runs with the ring correct every time.
|
||||
Both concurrency tests now start the writer only once the reader is running, repeat until the reader really read
|
||||
the ring while the writer wrote it, and require that; the small-ring test's old check also passed a reader that
|
||||
started after the writer had finished (`src/native/tests/ring_test.cpp`).
|
||||
|
||||
## [0.1.0-beta.22] - 2026-10-13
|
||||
|
||||
**The twenty-second pre-release: a request the capture agent never answered is said as such, never as a crash.** The
|
||||
|
||||
+36
-16
@@ -2297,7 +2297,13 @@ sent* ("nothing was deleted", "nothing changed"): a request the connection close
|
||||
connected" would read a disposed pipe as "nothing was sent". `AgentConnection` turns it into the `IOException` first,
|
||||
so the callers' split holds.
|
||||
|
||||
**Owner-only, added to the list below:** item 18.
|
||||
**Owner-only, added to the list below:** item 18 — **passed 2026-10-13**.
|
||||
|
||||
**After the release (owner, 2026-10-13):** "Tất cả các item đã đạt yêu cầu. Bạn có thể xử lý chip, phiên bản mới (nếu
|
||||
cần), cập nhật, rồi đóng phiên nhé" — items 16, 17 and 18 passed; the chip beta.22's local gate left (`fl_ring`'s
|
||||
hammering-writer guard, red on a correct ring) became beta.23 PR-1, #308: both concurrency cases guard on drains that
|
||||
overlapped the writer (§Traps, the native-test entry). Merged for the next pre-release; no release, since nothing a
|
||||
user runs changed.
|
||||
|
||||
## Owner-only — no PR can close these
|
||||
|
||||
@@ -2416,21 +2422,24 @@ sent* ("nothing was deleted", "nothing changed"): a request the connection close
|
||||
together are said in one notice that names both; with the USB drive unplugged nothing is removed; *Remove uninstalled
|
||||
games* off keeps it. (e) The Legal Gate shows the Privacy Policy 2.8
|
||||
once. (f) The `ja` strings marked `review`.
|
||||
16. **beta.20 on real hardware.** (a) **Bound Between Desks:** its page reads *Ren'Py 8.5.0*, and its *Engine version*
|
||||
line says it was read from the engine's version file (`renpy/vc_version.py`); the first sweep after the update reads
|
||||
every game once more (rules `2026.10.3`). (b) The Legal Gate shows the Privacy Policy 2.9 once. (c) The `ja` string
|
||||
marked `review` (`GameDetail_EngineVersion_RenPyVcVersion`).
|
||||
17. **beta.21 on real hardware.** (a) **Wuthering Waves:** after the update, before any session, its page says hooking
|
||||
is off — Anti-Cheat Expert beside its executable, and its Steam id on the title list; Neverness To Everness stays
|
||||
blocked, and GIRLS' FRONTLINE 2's exception stays in force. (b) **Play**, in both modes of Settings ▸ Games ▸ *Play
|
||||
button*, with a Steam game, Alan Wake 2 from the Epic Games Launcher (its link has not been tried on a real game), a
|
||||
GOG game and an itch game — and in Task Manager's Details tab the game's *Elevated* column reads *No*. (c) **The
|
||||
wheel and a touchpad** in Help ▸ User guide, the licence in Help ▸ About and the Legal Gate: about three lines a
|
||||
notch, gliding; at the end of the update notes the window scrolls instead. (d) The Legal Gate shows the Privacy
|
||||
Policy 2.10 once. (e) The `ja` strings marked `review` (Play, Settings ▸ Games, `GameDetail_Supports_None`).
|
||||
18. **beta.22 on real hardware.** (a) The `ja` string marked `review` (`Agent_Unanswered`). (b) Nothing else to run: the
|
||||
change answers a request the agent drops mid-way, which the tests make happen and a person can only meet by chance —
|
||||
if a notice ever says the capture agent did not answer, the page beside it shows what was stored.
|
||||
16. ~~**beta.20 on real hardware.**~~ **Passed 2026-10-13** — the owner: "Tất cả các item đã đạt yêu cầu" (every item
|
||||
met its requirement). *(The item as written:)* (a) **Bound Between Desks:** its page reads *Ren'Py 8.5.0*, and its
|
||||
*Engine version* line says it was read from the engine's version file (`renpy/vc_version.py`); the first sweep after
|
||||
the update reads every game once more (rules `2026.10.3`). (b) The Legal Gate shows the Privacy Policy 2.9 once. (c)
|
||||
The `ja` string marked `review` (`GameDetail_EngineVersion_RenPyVcVersion`).
|
||||
17. ~~**beta.21 on real hardware.**~~ **Passed 2026-10-13** — the same answer. *(The item as written:)* (a) **Wuthering
|
||||
Waves:** after the update, before any session, its page says hooking is off — Anti-Cheat Expert beside its
|
||||
executable, and its Steam id on the title list; Neverness To Everness stays blocked, and GIRLS' FRONTLINE 2's
|
||||
exception stays in force. (b) **Play**, in both modes of Settings ▸ Games ▸ *Play button*, with a Steam game, Alan
|
||||
Wake 2 from the Epic Games Launcher (its link has not been tried on a real game), a GOG game and an itch game — and
|
||||
in Task Manager's Details tab the game's *Elevated* column reads *No*. (c) **The wheel and a touchpad** in Help ▸
|
||||
User guide, the licence in Help ▸ About and the Legal Gate: about three lines a notch, gliding; at the end of the
|
||||
update notes the window scrolls instead. (d) The Legal Gate shows the Privacy Policy 2.10 once. (e) The `ja` strings
|
||||
marked `review` (Play, Settings ▸ Games, `GameDetail_Supports_None`).
|
||||
18. ~~**beta.22 on real hardware.**~~ **Passed 2026-10-13** — the same answer. *(The item as written:)* (a) The `ja`
|
||||
string marked `review` (`Agent_Unanswered`). (b) Nothing else to run: the change answers a request the agent drops
|
||||
mid-way, which the tests make happen and a person can only meet by chance — if a notice ever says the capture agent
|
||||
did not answer, the page beside it shows what was stored.
|
||||
|
||||
**Answered 2026-08-05, do not re-ask:** remove `gameguard` and keep `guard` (approved
|
||||
over a red `Rules` gate, with the reasoning recorded in the merge commit); vendor NVAPI
|
||||
@@ -2673,6 +2682,17 @@ diagnosis*.
|
||||
nothing, and `ring_test.cpp`'s own header already records that two of its four properties
|
||||
have never been shown red.
|
||||
|
||||
> **Amended 2026-10-13 (beta.23 PR-1, #308): both guards now measure overlap.** The hammering case's own guard,
|
||||
> `accepted > kTotal / 2`, failed 5 of 40 runs and then 5 of 200 on the owner's hybrid i7-14700KF — `mixed` clean every
|
||||
> time — and once made a full local gate red. A share of the stream measured the scheduler: a reader on an efficiency
|
||||
> core keeps less than half, and one the OS does not run until the writer is done keeps one lap (accepted 1024). The
|
||||
> tiny ring's `dropped > 0` was weaker the other way: a reader made to wait for the writer to finish drops nearly
|
||||
> everything (1.6 million over eight attempts) and passed it. Both cases now start the writer only once the reader
|
||||
> is about to loop, count the drains that copied records while the writer was still writing, and repeat — every
|
||||
> attempt checked for its properties — until one attempt made 100 such drains, at most eight times; the tiny ring
|
||||
> also holds that attempt's own `dropped > 0`. A start barrier alone left 1 of 200 (one overlapping drain). Measured:
|
||||
> 1,000 runs, no failure, at most 3 attempts; with the waiting reader, both guards fail in every run.
|
||||
|
||||
- **A self-test's cases can all pass while testing nothing, and their NAMES will not tell
|
||||
you.** Found 2026-08-27 in a PowerShell gate's `-SelfTest`: removing the fail-closed guard
|
||||
from a hash comparison left **all ten cases green**. `[string]::Equals` already refuses
|
||||
|
||||
+124
-70
@@ -33,6 +33,7 @@
|
||||
// added trying to close it and did not; they are kept because they are the right
|
||||
// shape and would catch a wider window.
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <cstring>
|
||||
@@ -246,6 +247,18 @@ TEST_CASE("a reader stalled exactly ONE FULL LAP does not accept a stale frame",
|
||||
CHECK(out[0].frameIndex == kCap); // the SECOND occupant, not the first
|
||||
}
|
||||
|
||||
// What makes the two concurrency cases below prove anything is that the reader drained the ring WHILE the writer
|
||||
// wrote it (2026-10-13). The hammering case's guard was `accepted > kTotal / 2`, a share of the stream, and that
|
||||
// measured the scheduler rather than the run: on the owner's hybrid i7-14700KF it failed 5 of 40 runs, then 5 of 200,
|
||||
// with `mixed` clean every time. A start barrier (the writer begins only once the reader is about to loop) left 1 of
|
||||
// 200 — a reader the OS did not run while the writer wrote: one drain beside it, accepted 2048. No single run can rule
|
||||
// that out, so each case repeats its run, every attempt checked for its properties, until one attempt made enough
|
||||
// drains that copied records while the writer was still writing. Measured over 1,000 runs: no failure, at most 3
|
||||
// attempts, at least 122 such drains in the best attempt (median 146,981). A reader made to wait for the writer to
|
||||
// finish makes none in all 8 attempts and fails here, where the tiny ring's old `dropped > 0` still passed.
|
||||
constexpr std::uint64_t kMinOverlappedDrains = 100;
|
||||
constexpr int kMaxAttempts = 8;
|
||||
|
||||
TEST_CASE("SPSC under a hammering writer: every accepted record is internally consistent", "[ring]") {
|
||||
// The real concurrency case. The reader may legitimately miss records
|
||||
// (overwrite-oldest) and may see torn ones; what it must NEVER do is accept a
|
||||
@@ -254,44 +267,63 @@ TEST_CASE("SPSC under a hammering writer: every accepted record is internally co
|
||||
constexpr std::uint32_t kBigCap = 1024;
|
||||
constexpr std::uint32_t kTotal = 200000;
|
||||
|
||||
Mapping m{kBigCap};
|
||||
RingWriter w;
|
||||
RingReader rd;
|
||||
REQUIRE(w.Init(m.base(), kBigCap));
|
||||
REQUIRE(rd.Init(m.base(), kBigCap));
|
||||
std::uint64_t mostOverlapped = 0;
|
||||
int attempts = 0;
|
||||
while (mostOverlapped < kMinOverlappedDrains && attempts < kMaxAttempts) {
|
||||
++attempts;
|
||||
Mapping m{kBigCap};
|
||||
RingWriter w;
|
||||
RingReader rd;
|
||||
REQUIRE(w.Init(m.base(), kBigCap));
|
||||
REQUIRE(rd.Init(m.base(), kBigCap));
|
||||
|
||||
std::atomic<bool> done{false};
|
||||
std::thread producer([&] {
|
||||
for (std::uint32_t i = 0; i < kTotal; ++i) {
|
||||
w.Publish(MakeRecord(i));
|
||||
}
|
||||
done.store(true, std::memory_order_release);
|
||||
});
|
||||
|
||||
std::vector<FlFrameRecord> buf(kBigCap);
|
||||
std::uint64_t accepted = 0;
|
||||
std::uint64_t torn = 0;
|
||||
bool mixed = false;
|
||||
|
||||
while (!done.load(std::memory_order_acquire) || rd.ReadIndex() < m.writer()->writeIndex) {
|
||||
const DrainResult r = rd.Drain(buf.data(), kBigCap);
|
||||
for (std::uint32_t i = 0; i < r.copied; ++i) {
|
||||
if (buf[i].qpc != 1000ULL + buf[i].frameIndex) {
|
||||
mixed = true;
|
||||
std::atomic<bool> go{false};
|
||||
std::atomic<bool> done{false};
|
||||
std::thread producer([&] {
|
||||
while (!go.load(std::memory_order_acquire)) {
|
||||
std::this_thread::yield();
|
||||
}
|
||||
if (buf[i].swapchainId != (0xABCD0000u | (buf[i].frameIndex & 0xFFFFu))) {
|
||||
mixed = true; // the tail span belongs to the same frame as the head
|
||||
for (std::uint32_t i = 0; i < kTotal; ++i) {
|
||||
w.Publish(MakeRecord(i));
|
||||
}
|
||||
done.store(true, std::memory_order_release);
|
||||
});
|
||||
|
||||
std::vector<FlFrameRecord> buf(kBigCap);
|
||||
std::uint64_t accepted = 0;
|
||||
std::uint64_t torn = 0;
|
||||
std::uint64_t overlapped = 0; // drains that copied records while the writer was writing
|
||||
bool mixed = false;
|
||||
|
||||
go.store(true, std::memory_order_release);
|
||||
while (!done.load(std::memory_order_acquire) || rd.ReadIndex() < m.writer()->writeIndex) {
|
||||
const bool writing = !done.load(std::memory_order_acquire);
|
||||
const DrainResult r = rd.Drain(buf.data(), kBigCap);
|
||||
for (std::uint32_t i = 0; i < r.copied; ++i) {
|
||||
if (buf[i].qpc != 1000ULL + buf[i].frameIndex) {
|
||||
mixed = true;
|
||||
}
|
||||
if (buf[i].swapchainId != (0xABCD0000u | (buf[i].frameIndex & 0xFFFFu))) {
|
||||
mixed = true; // the tail span belongs to the same frame as the head
|
||||
}
|
||||
}
|
||||
if (writing && r.copied > 0) {
|
||||
++overlapped;
|
||||
}
|
||||
accepted += r.copied;
|
||||
torn += r.gaps;
|
||||
}
|
||||
accepted += r.copied;
|
||||
torn += r.gaps;
|
||||
producer.join();
|
||||
|
||||
INFO("attempt " << attempts << ": accepted " << accepted << ", torn " << torn << ", overlapped drains "
|
||||
<< overlapped << " of " << kTotal);
|
||||
CHECK_FALSE(mixed);
|
||||
mostOverlapped = std::max(mostOverlapped, overlapped);
|
||||
}
|
||||
producer.join();
|
||||
|
||||
INFO("accepted " << accepted << ", torn " << torn << " of " << kTotal);
|
||||
CHECK_FALSE(mixed);
|
||||
// Not a vacuous run: the reader must actually have seen most of the stream.
|
||||
CHECK(accepted > kTotal / 2);
|
||||
INFO("attempts " << attempts << ", most overlapped drains " << mostOverlapped);
|
||||
// Not a vacuous run: in one attempt at least, the reader read the ring while the writer was writing it.
|
||||
CHECK(mostOverlapped >= kMinOverlappedDrains);
|
||||
}
|
||||
|
||||
TEST_CASE("a tiny ring, so the writer laps the reader constantly", "[ring]") {
|
||||
@@ -307,50 +339,72 @@ TEST_CASE("a tiny ring, so the writer laps the reader constantly", "[ring]") {
|
||||
constexpr std::uint32_t kTiny = 8;
|
||||
constexpr std::uint32_t kTotal = 200000;
|
||||
|
||||
Mapping m{kTiny};
|
||||
RingWriter w;
|
||||
RingReader rd;
|
||||
REQUIRE(w.Init(m.base(), kTiny));
|
||||
REQUIRE(rd.Init(m.base(), kTiny));
|
||||
std::uint64_t mostOverlapped = 0;
|
||||
std::uint64_t dropped = 0; // the last attempt's: the one that overlapped, when one did
|
||||
int attempts = 0;
|
||||
while (mostOverlapped < kMinOverlappedDrains && attempts < kMaxAttempts) {
|
||||
++attempts;
|
||||
Mapping m{kTiny};
|
||||
RingWriter w;
|
||||
RingReader rd;
|
||||
REQUIRE(w.Init(m.base(), kTiny));
|
||||
REQUIRE(rd.Init(m.base(), kTiny));
|
||||
|
||||
std::atomic<bool> done{false};
|
||||
std::thread producer([&] {
|
||||
for (std::uint32_t i = 0; i < kTotal; ++i) {
|
||||
w.Publish(MakeRecord(i));
|
||||
}
|
||||
done.store(true, std::memory_order_release);
|
||||
});
|
||||
|
||||
FlFrameRecord buf[kTiny]{};
|
||||
std::uint64_t accepted = 0;
|
||||
std::uint64_t dropped = 0;
|
||||
bool mixed = false;
|
||||
bool poisonAccepted = false;
|
||||
|
||||
while (!done.load(std::memory_order_acquire) || rd.ReadIndex() < m.writer()->writeIndex) {
|
||||
const DrainResult r = rd.Drain(buf, kTiny);
|
||||
for (std::uint32_t i = 0; i < r.copied; ++i) {
|
||||
if (buf[i].qpc != 1000ULL + buf[i].frameIndex ||
|
||||
buf[i].swapchainId != (0xABCD0000u | (buf[i].frameIndex & 0xFFFFu))) {
|
||||
mixed = true;
|
||||
std::atomic<bool> go{false};
|
||||
std::atomic<bool> done{false};
|
||||
std::thread producer([&] {
|
||||
while (!go.load(std::memory_order_acquire)) {
|
||||
std::this_thread::yield();
|
||||
}
|
||||
// An accepted record's seq is the seqlock counter and must be even.
|
||||
// kPoisonSeq here means the payload write reached the guard field.
|
||||
if (buf[i].seq == kPoisonSeq || (buf[i].seq & 1u) != 0u) {
|
||||
poisonAccepted = true;
|
||||
for (std::uint32_t i = 0; i < kTotal; ++i) {
|
||||
w.Publish(MakeRecord(i));
|
||||
}
|
||||
done.store(true, std::memory_order_release);
|
||||
});
|
||||
|
||||
FlFrameRecord buf[kTiny]{};
|
||||
std::uint64_t accepted = 0;
|
||||
std::uint64_t lost = 0;
|
||||
std::uint64_t overlapped = 0; // drains that copied records while the writer was writing
|
||||
bool mixed = false;
|
||||
bool poisonAccepted = false;
|
||||
|
||||
go.store(true, std::memory_order_release);
|
||||
while (!done.load(std::memory_order_acquire) || rd.ReadIndex() < m.writer()->writeIndex) {
|
||||
const bool writing = !done.load(std::memory_order_acquire);
|
||||
const DrainResult r = rd.Drain(buf, kTiny);
|
||||
for (std::uint32_t i = 0; i < r.copied; ++i) {
|
||||
if (buf[i].qpc != 1000ULL + buf[i].frameIndex ||
|
||||
buf[i].swapchainId != (0xABCD0000u | (buf[i].frameIndex & 0xFFFFu))) {
|
||||
mixed = true;
|
||||
}
|
||||
// An accepted record's seq is the seqlock counter and must be even.
|
||||
// kPoisonSeq here means the payload write reached the guard field.
|
||||
if (buf[i].seq == kPoisonSeq || (buf[i].seq & 1u) != 0u) {
|
||||
poisonAccepted = true;
|
||||
}
|
||||
}
|
||||
if (writing && r.copied > 0) {
|
||||
++overlapped;
|
||||
}
|
||||
accepted += r.copied;
|
||||
lost += r.dropped;
|
||||
}
|
||||
accepted += r.copied;
|
||||
dropped += r.dropped;
|
||||
producer.join();
|
||||
dropped = lost;
|
||||
|
||||
INFO("attempt " << attempts << ": accepted " << accepted << ", overlapped drains " << overlapped << " of "
|
||||
<< kTotal);
|
||||
CHECK_FALSE(mixed);
|
||||
CHECK_FALSE(poisonAccepted);
|
||||
mostOverlapped = std::max(mostOverlapped, overlapped);
|
||||
}
|
||||
producer.join();
|
||||
|
||||
INFO("accepted " << accepted << ", dropped " << dropped << " of " << kTotal);
|
||||
CHECK_FALSE(mixed);
|
||||
CHECK_FALSE(poisonAccepted);
|
||||
// Not vacuous in the other direction either: with 8 slots the writer MUST
|
||||
// have lapped us, so a run reporting no drops means the threads never
|
||||
// actually overlapped and the case proved nothing.
|
||||
INFO("attempts " << attempts << ", most overlapped drains " << mostOverlapped << ", dropped " << dropped);
|
||||
// Not vacuous: the reader read the ring while the writer was writing it. `dropped > 0` alone could not say so — a
|
||||
// reader that started after the writer had finished drops nearly everything — and with eight slots the attempt
|
||||
// that overlapped (the last one) is lapped, which the second check holds it to.
|
||||
CHECK(mostOverlapped >= kMinOverlappedDrains);
|
||||
CHECK(dropped > 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user