Skip to content

Commit 1444aaf

Browse files
committed
The compiler witness asks again for a record Windows refuses; the matrix scan reports supervision lines
1 parent fe43d66 commit 1444aaf

3 files changed

Lines changed: 33 additions & 9 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@
5353
- A test of an unchanged project that this host cannot execute is reported for
5454
the host's target: `mcpp test` without planning (2026.11.10.1) named an empty
5555
target in the refusal and in the `[target.…].runner` it proposes.
56+
- A compiler record that Windows refuses to a reader for longer than the
57+
publication bound is asked for again at the witness's next audit, as an
58+
unknown controller already was; the refusal ends the build only when it
59+
outlasts the startup grace. It ended a Windows build with "a compiler
60+
controller ended before completion" after a large package installation. The
61+
target-matrix scan reports the supervision's own `mcpp:` lines with a failed
62+
cell.
5663

5764
## [2026.11.10.1] - 2026-11-10
5865

‎src/build/schedule/compiler_transaction.cppm‎

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ inline constexpr auto kRecordSettle=std::chrono::milliseconds(250);
5353
// registering its unit with the generation's owner. One bound for both, so a
5454
// registration retried within it never outlives the wait for it.
5555
inline constexpr auto kStartupGrace=std::chrono::seconds(10);
56+
// A record that exists and is still refused after kRecordSettle. The refusal
57+
// is a fact about the moment, not about the record's content.
58+
inline constexpr std::string_view kRecordUnreadable="cannot read compiler transaction record";
5659
enum class Opened { yes, absent, refused };
5760
// Opens `path' for reading, waiting out a publication in progress.
5861
Opened open_settled(std::ifstream& input,const fs::path& path) {
@@ -76,10 +79,10 @@ Record read(const fs::path& path, std::string_view tag) {
7679
std::ifstream input;
7780
const auto opened=open_settled(input,path);
7881
if(opened==Opened::absent)return std::optional<Fields>{};
79-
if(opened==Opened::refused)return std::unexpected("cannot read compiler transaction record");
82+
if(opened==Opened::refused)return std::unexpected(std::string(kRecordUnreadable));
8083
std::string bytes(65537,'\0');
8184
input.read(bytes.data(),bytes.size());bytes.resize(static_cast<std::size_t>(input.gcount()));
82-
if(input.bad())return std::unexpected("cannot read compiler transaction record");
85+
if(input.bad())return std::unexpected(std::string(kRecordUnreadable));
8386
if (bytes.size() < 18 || bytes.size() > 65536 || bytes[bytes.size()-18] != '\n' || bytes.back() != '\n')
8487
return std::unexpected("corrupt compiler transaction record");
8588
const auto body = std::string_view(bytes).substr(0,bytes.size()-18);
@@ -438,6 +441,18 @@ private:
438441
std::atomic<bool> stopping_{false},failed_{false};
439442
std::mutex admission_;
440443
ObserverMap held_;
444+
// AN UNREADABLE RECORD IS ASKED AGAIN AT THE NEXT AUDIT, as an unknown
445+
// controller is. A Windows reader can be refused a just-published record
446+
// for longer than kRecordSettle while the host scans new files; the
447+
// refusal decides the loss of a compiler only when it outlasts the
448+
// startup grace. Corrupt content is decided at once.
449+
std::map<std::string,std::chrono::steady_clock::time_point> unreadable_;
450+
bool settling(const std::string& attempt,std::string_view error) {
451+
if(error!=kRecordUnreadable)return false;
452+
const auto now=std::chrono::steady_clock::now();
453+
const auto first=unreadable_.try_emplace(attempt,now).first->second;
454+
return now-first<kStartupGrace;
455+
}
441456
void fail(std::string_view reason) {
442457
if(!failed_.exchange(true))
443458
std::println(std::cerr,"mcpp: compiler witness: {}",reason);
@@ -446,20 +461,21 @@ private:
446461
for(auto it=held_.begin();it!=held_.end();) {
447462
const auto directory=named(it->first);
448463
auto retired=read(directory/"retired","mcpp-retired-v1");
449-
if(!retired) {fail(retired.error());++it;continue;}
464+
if(!retired) {if(!settling(it->first,retired.error()))fail(retired.error());++it;continue;}
450465
if(*retired&&(**retired).size()!=3) {fail("invalid retirement certificate");++it;continue;}
451-
if(*retired) {it=held_.erase(it);continue;}
466+
if(*retired) {unreadable_.erase(it->first);it=held_.erase(it);continue;}
452467
auto attempt=Attempt::load(directory);
453-
if(!attempt) {fail(attempt.error());++it;continue;}
468+
if(!attempt) {if(!settling(it->first,attempt.error()))fail(attempt.error());++it;continue;}
469+
unreadable_.erase(it->first);
454470
const auto state=controller_state(*attempt);
455471
if(state==Controller::unknown) {++it;continue;} // asked again at the next audit
456472
if(state==Controller::ended) {
457473
// Retirement can be published between the first read and the
458474
// controller's exit. Observe it again before reporting loss.
459475
retired=read(directory/"retired","mcpp-retired-v1");
460-
if(!retired)fail(retired.error());
476+
if(!retired) {if(!settling(it->first,retired.error()))fail(retired.error());}
461477
else if(*retired&&(**retired).size()!=3)fail("invalid retirement certificate");
462-
else if(*retired) {it=held_.erase(it);continue;}
478+
else if(*retired) {unreadable_.erase(it->first);it=held_.erase(it);continue;}
463479
else fail("controller ended without retirement certificate");
464480
}
465481
++it;

‎tests/matrix/scan.sh‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,10 @@ for tc in $(compilers); do
279279
# 这里只留错误行,不倒整份构建日志 —— 40 格 × 一份完整日志读不动。
280280
# 三行,**整行**。前一版 `cut -c1-160` 把真正的错误砍在半路 ——
281281
# macOS 那格只留下 `precompiled file '/private/var/…/target/` 就没了,
282-
# 而要看的正是后半截。判据的单位是一整行输出。
282+
# 而要看的正是后半截。判据的单位是一整行输出。`mcpp:` 行是编译器
283+
# 监督自身的陈述(哪一次观察判定了失败),它不带 `error:`,却是原因。
283284
echo "scan: $t × $tc 构建失败:" >&2
284-
grep -m3 -iE '^error|error:' "$work/b.out" | sed 's/^/ /' >&2
285+
grep -m4 -iE '^error|error:|^mcpp: ' "$work/b.out" | sed 's/^/ /' >&2
285286
emit "$MODE" "$HOST" "$t" "$tc" "$tri" "$clib" "$cabi" "$cxxabi" "$okpkg" \
286287
mismatch build-failed
287288
fi

0 commit comments

Comments
 (0)