Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
193 commits
Select commit Hold shift + click to select a range
579c4b0
rrr: re-enable borrow checking across modular code
shuaimu May 17, 2026
2b85ff8
rrr: drop 24 borrow-check findings to 2 via rusty-cpp annotation fixes
shuaimu May 17, 2026
28e64c5
rrr: bump rusty-cpp for import-chasing + multi-line @unsafe block fixes
shuaimu May 17, 2026
52037ff
rrr: zero out the 11 remaining borrow-check findings in client.cpp
shuaimu May 17, 2026
9794735
rrr: expand RRR_BORROW_SRC to all 43 borrow-checkable module units
shuaimu May 17, 2026
0c16ebf
rrr: include server.cpp + fiber_channel.cpp in borrow check (via cras…
shuaimu May 17, 2026
f72f369
docs/dev: write up libclang-22 parse-crash investigation
shuaimu May 18, 2026
df2388f
rrr: switch production toolchain to clang-21; reconcile borrow-check …
shuaimu May 18, 2026
8f62ed8
rrr/reactor: switch class-static thread_locals to `static inline thre…
shuaimu May 18, 2026
80732a4
build/docs: switch toolchain-detect + writeups to clang-21 production
shuaimu May 18, 2026
95ed6d0
rrr: tier 1 annotation flips — 15 functions unsafe → safe
shuaimu May 18, 2026
183508d
rrr: tier 2 annotation flips — flip VecDeque / Function / RequestQueu…
shuaimu May 18, 2026
01b1480
rrr/rpc: tier 3 — migrate ClientPool's raw SpinLock to SpinMutex<Pool…
shuaimu May 18, 2026
930f40f
rrr/rpc: tier 4 — drop class-level @unsafe escape hatches on Future +…
shuaimu May 18, 2026
9e7d427
rrr/rpc: tier 5 first pass — drop 19 stale `// @unsafe { ... }` wrapp…
shuaimu May 18, 2026
1e6ede9
rrr: tier 5 second pass — drop 5 more stale `// @unsafe { ... }` wrap…
shuaimu May 18, 2026
da9bb78
docs/dev: plan to push rrr @safe LOC ratio from ~6% to 80%
shuaimu May 18, 2026
e333682
scripts: relocate rrr safety LOC tally into repo, fix out-of-class match
shuaimu May 18, 2026
54a2d98
rrr: tier-plan iter 2 — Server class @safe; LOC script ;-in-comment fix
shuaimu May 18, 2026
9784267
docs/dev/rrr_safety_80pct_plan: correct commit SHA in Progress log
shuaimu May 18, 2026
af6db92
rrr/reactor: tier-plan iter 3 — Reactor class @safe
shuaimu May 18, 2026
6560958
docs/dev/rrr_safety_80pct_plan: backfill Reactor commit SHA
shuaimu May 18, 2026
1f4d6b5
rrr: tier-plan iter 4 — IdempotencyKeyGenerator + IdempotencyCache @s…
shuaimu May 18, 2026
68eaa96
docs/dev/rrr_safety_80pct_plan: backfill idempotency commit SHA
shuaimu May 18, 2026
ce802ff
rrr/rpc: tier-plan iter 5 — CompletionTracker class @safe
shuaimu May 18, 2026
aabd1df
docs/dev/rrr_safety_80pct_plan: CompletionTracker SHA backfill
shuaimu May 18, 2026
a12f0ee
rrr/rpc: tier-plan iter 6 — CircuitBreaker class @safe
shuaimu May 18, 2026
ded5e82
docs/dev/rrr_safety_80pct_plan: CircuitBreaker SHA backfill
shuaimu May 18, 2026
8f4bf96
rrr/rpc: tier-plan iter 7 — HeartbeatManager class @safe
shuaimu May 18, 2026
2dbeced
docs/dev/rrr_safety_80pct_plan: HeartbeatManager SHA backfill
shuaimu May 18, 2026
ed12702
rrr/rpc: tier-plan iter 8 — ConnectionStateMachine class @safe
shuaimu May 18, 2026
bed8c30
docs/dev/rrr_safety_80pct_plan: ConnectionStateMachine SHA backfill
shuaimu May 18, 2026
b209eb8
rrr: tier-plan iter 9 — TcpListener class @safe + LOC script namespac…
shuaimu May 19, 2026
9379d76
docs/dev/rrr_safety_80pct_plan: TcpListener SHA backfill
shuaimu May 19, 2026
d4ea853
rrr/rpc: tier-plan iter 10 — LoadBalancer + LoadBalancerState @safe
shuaimu May 19, 2026
6ca6f4e
docs/dev/rrr_safety_80pct_plan: LoadBalancer SHA backfill
shuaimu May 19, 2026
75496f6
rrr/rpc: tier-plan iter 11 — RequestQueue class @safe
shuaimu May 19, 2026
bd35b85
docs/dev/rrr_safety_80pct_plan: RequestQueue SHA backfill
shuaimu May 19, 2026
d8ea432
docs/dev/rrr_safety_80pct_plan: inmemory_channel.cpp blocked
shuaimu May 19, 2026
52ca4d5
docs/dev/rrr_safety_80pct_plan: frame_codec.cpp blocked
shuaimu May 19, 2026
fc9be1a
rrr/rpc: tier-plan iter 14 — internal_protocol.cpp namespace @safe
shuaimu May 19, 2026
cdee671
docs/dev/rrr_safety_80pct_plan: internal_protocol SHA backfill
shuaimu May 19, 2026
eabaffe
rrr/rpc: tier-plan iter 15 — request_options.cpp namespace @safe
shuaimu May 19, 2026
ea7e921
docs/dev/rrr_safety_80pct_plan: request_options SHA backfill
shuaimu May 19, 2026
fa602d6
rrr/rpc: tier-plan iter 16 — connection_metrics.cpp namespace @safe
shuaimu May 19, 2026
cf6b4ca
docs/dev/rrr_safety_80pct_plan: connection_metrics SHA backfill
shuaimu May 19, 2026
87eb79b
rrr: tier-plan iter 17 — callbacks.cpp @safe + LOC script namespace
shuaimu May 19, 2026
4245cdd
docs/dev/rrr_safety_80pct_plan: callbacks SHA backfill
shuaimu May 19, 2026
6707c2e
rrr/rpc: tier-plan iter 18 — errors.cpp namespace @safe
shuaimu May 19, 2026
12d7dda
docs/dev/rrr_safety_80pct_plan: errors SHA backfill
shuaimu May 19, 2026
603890c
docs/dev/rrr_safety_80pct_plan: utils.cpp blocked — pure syscall wrap…
shuaimu May 19, 2026
9bb655b
rrr/rpc: tier-plan iter 20 — pollable_proxy.cpp namespace @safe
shuaimu May 19, 2026
ca24d87
docs/dev/rrr_safety_80pct_plan: pollable_proxy SHA backfill
shuaimu May 19, 2026
b460ca7
rrr/rpc: tier-plan iter 21 — reconnect_policy.cpp namespace @safe
shuaimu May 19, 2026
88e67d0
docs/dev/rrr_safety_80pct_plan: reconnect_policy SHA backfill
shuaimu May 19, 2026
a1ff0e9
docs/dev/rrr_safety_80pct_plan: serializable_envelope.cpp blocked
shuaimu May 19, 2026
4c9c466
docs/dev/rrr_safety_80pct_plan: netinfo.cpp blocked — std::ifstream +…
shuaimu May 19, 2026
a9bb96c
rrr/misc: tier-plan iter 24 — stat.cpp namespace @safe; 20% MILESTONE
shuaimu May 19, 2026
14062ae
docs/dev/rrr_safety_80pct_plan: stat.cpp SHA backfill
shuaimu May 19, 2026
abd56e7
docs/dev/rrr_safety_80pct_plan: cpuinfo.cpp blocked — /proc + times()
shuaimu May 19, 2026
1b633ec
rrr/misc: tier-plan iter 26 — rand.cpp RandomGenerator @safe
shuaimu May 19, 2026
09879d1
docs/dev/rrr_safety_80pct_plan: rand.cpp SHA backfill
shuaimu May 19, 2026
5f2b079
rrr/misc: tier-plan iter 27 — dball.cpp DragonBall @safe
shuaimu May 19, 2026
6dcd209
docs/dev/rrr_safety_80pct_plan: dball.cpp SHA backfill
shuaimu May 19, 2026
a64a2a9
rrr/misc: tier-plan iter 28 — alarm.cpp Alarm @safe
shuaimu May 19, 2026
2fc6e20
docs/dev/rrr_safety_80pct_plan: alarm.cpp SHA backfill
shuaimu May 19, 2026
0cf788a
rrr/base: tier-plan iter 29 — basetypes.cpp dual-namespace @safe
shuaimu May 19, 2026
8803080
docs/dev/rrr_safety_80pct_plan: basetypes.cpp SHA backfill
shuaimu May 19, 2026
e3458ed
rrr/base: tier-plan iter 30 — debugging.cpp dual-namespace @safe
shuaimu May 19, 2026
bd006f8
docs/dev/rrr_safety_80pct_plan: debugging.cpp SHA backfill
shuaimu May 19, 2026
1dc137d
rrr/base: tier-plan iter 31 — strop.cpp namespace @safe
shuaimu May 19, 2026
bd633ae
docs/dev/rrr_safety_80pct_plan: strop.cpp SHA backfill
shuaimu May 19, 2026
b82e63f
rrr/base: tier-plan iter 32 — callback_wrapper.cpp dual @safe
shuaimu May 19, 2026
5d18f34
docs/dev/rrr_safety_80pct_plan: callback_wrapper.cpp SHA backfill
shuaimu May 19, 2026
14f4d54
rrr/base: tier-plan iter 33 — misc.cpp dual-namespace @safe
shuaimu May 19, 2026
f636402
docs/dev/rrr_safety_80pct_plan: misc.cpp SHA backfill
shuaimu May 19, 2026
714b2aa
rrr/base: tier-plan iter 34 — unittest.cpp dual-namespace @safe
shuaimu May 19, 2026
96dccd8
docs/dev/rrr_safety_80pct_plan: unittest.cpp SHA backfill
shuaimu May 19, 2026
596d31e
rrr/reactor: tier-plan iter 35 — epoll_wrapper.cc dual-namespace @safe
shuaimu May 19, 2026
acb031c
docs/dev/rrr_safety_80pct_plan: epoll_wrapper.cc SHA backfill
shuaimu May 19, 2026
05b6c69
docs/dev/rrr_safety_80pct_plan: ChannelConnectionProxy/FactoryProxy b…
shuaimu May 19, 2026
0c7daa4
docs/dev/rrr_safety_80pct_plan: PollThreadWorker* blocked
shuaimu May 19, 2026
e45fb24
docs/dev/rrr_safety_80pct_plan: rusty::sys wrappers blocked + stop loop
shuaimu May 19, 2026
eaaab68
docs/dev/rrr_safety_80pct_plan: add Phase 1 unblock retries subplan
shuaimu May 19, 2026
98322cc
rrr/rpc: tier-plan iter 39 — inmemory_channel.cpp unblock retry
shuaimu May 19, 2026
18e9bdc
docs/dev/rrr_safety_80pct_plan: inmemory_channel.cpp SHA backfill
shuaimu May 19, 2026
a543ab5
rrr/rpc: tier-plan iter 40 — utils.cpp unblock retry
shuaimu May 19, 2026
6e69e5d
docs/dev/rrr_safety_80pct_plan: utils.cpp SHA backfill
shuaimu May 19, 2026
7e7d995
rrr: tier-plan iter 41 — SP-1 rusty::sys::fs library wrapper landed
shuaimu May 19, 2026
88af060
docs/dev/rrr_safety_80pct_plan: SP-1 SHA backfill
shuaimu May 19, 2026
3699b21
rrr/misc: tier-plan iter 42 — netinfo.cpp unblock via rusty::sys::fs
shuaimu May 19, 2026
45042d7
docs/dev/rrr_safety_80pct_plan: netinfo.cpp SHA backfill
shuaimu May 19, 2026
df8483b
rrr/misc: tier-plan iter 43 — cpuinfo.cpp unblock retry
shuaimu May 19, 2026
80b0c89
docs/dev/rrr_safety_80pct_plan: cpuinfo.cpp SHA backfill
shuaimu May 19, 2026
060223e
rrr: tier-plan iter 44 — SP-5 Cursor<T> annotated @safe
shuaimu May 19, 2026
0f6f273
docs/dev/rrr_safety_80pct_plan: SP-5 SHA backfill
shuaimu May 19, 2026
c5f5ee7
rrr/rpc: tier-plan iter 45 — frame_codec.cpp unblock retry
shuaimu May 19, 2026
88d4109
docs/dev/rrr_safety_80pct_plan: frame_codec.cpp SHA backfill
shuaimu May 19, 2026
7fa7a0b
rrr/misc: tier-plan iter 46 — serializable_envelope.cpp unblock retry
shuaimu May 19, 2026
865c5bf
docs/dev/rrr_safety_80pct_plan: serializable_envelope.cpp SHA backfill
shuaimu May 19, 2026
4b1ad9b
docs/dev/rrr_safety_80pct_plan: tick the Phase 1 candidate list
shuaimu May 19, 2026
97ab8d4
rrr/rpc: tier-plan iter 47 — Service::__get_service__ returns Service&
shuaimu May 19, 2026
29ea9ae
docs/dev/rrr_safety_80pct_plan: ServiceProxy SHA backfill
shuaimu May 19, 2026
e47c695
docs/dev/rrr_safety_80pct_plan: ALock* blocked
shuaimu May 19, 2026
19da6cb
docs/dev/rrr_safety_80pct_plan: shared_ptr<Marshallable> → Arc blocked
shuaimu May 19, 2026
b9d73b6
docs/dev/rrr_safety_80pct_plan: Reactor::loop scoping blocked + loop …
shuaimu May 19, 2026
e685003
rrr/misc: marshal.cpp namespace + class @safe (Phase 4 labeling)
shuaimu May 19, 2026
7bc1585
docs/dev/rrr_safety_80pct_plan: marshal.cpp SHA backfill
shuaimu May 19, 2026
19fecd5
rrr/misc: any_message.cpp namespace + class @safe
shuaimu May 19, 2026
362f0b1
rrr/rpc: channel.cpp namespace @safe
shuaimu May 19, 2026
7921358
rrr/rpc: fiber_channel.cpp namespace + class @safe
shuaimu May 19, 2026
25c0f63
rrr/reactor: future.cpp namespace + class @safe
shuaimu May 19, 2026
0b7a56c
rrr/base: logging.cpp namespace + class @safe (closes T1 sweep)
shuaimu May 19, 2026
5764deb
rrr/misc: alock.cpp namespace + class @safe (T2 labeling pass)
shuaimu May 19, 2026
68c384d
rrr/rpc: tcp_channel.cpp namespace + classes @safe (T2 sweep)
shuaimu May 19, 2026
6ce00ab
rrr/rpc: client.cpp namespace umbrella @safe (crosses 50% threshold)
shuaimu May 19, 2026
1239e18
rrr/rpc: server.cpp namespace umbrella + class @safe (Phase 1 sweep)
shuaimu May 20, 2026
fbbe4f4
docs/dev/rrr_safety_80pct_plan: server.cpp SHA backfill
shuaimu May 20, 2026
882f422
third-party/rusty-cpp: bump submodule to 07e9f13 (init-tracker fix + …
shuaimu May 20, 2026
d5ec61e
third-party/rusty-cpp: bump to 09457e7 (anon-ns annotation matching fix)
shuaimu May 20, 2026
c703344
third-party/rusty-cpp: bump to 114c2cd (rrr now 45/45 clean)
shuaimu May 20, 2026
8eb86b1
rrr/misc: serializable.cpp namespace umbrella @safe (Phase 1 sweep)
shuaimu May 20, 2026
8c08546
rrr/reactor: reactor.cpp namespace umbrella @safe + rusty-cpp pin bump
shuaimu May 20, 2026
8c7b09a
rrr/reactor: flip Reactor::loop from @unsafe to @safe (Phase 3 unblock)
shuaimu May 20, 2026
c8c6bda
docs/dev/rrr_safety_80pct_plan: mark Reactor::loop scoping done
shuaimu May 20, 2026
3963cd1
third-party/rusty-cpp: bump to 5d6ed56 (add rusty::os::fd)
shuaimu May 20, 2026
f2fd5ff
rrr/rpc: TcpConnection / TcpListener — migrate int fd_ to rusty::os::…
shuaimu May 20, 2026
905c9da
third-party/rusty-cpp: bump to 2fbfab9 (rusty::net::Tcp{Listener,Stre…
shuaimu May 20, 2026
9321cf6
rrr/rpc: rewire TcpListener + TcpFactory through rusty::net::* (Phase C)
shuaimu May 20, 2026
4f3652a
rrr/tests: fix pre-existing breakage in 7 test files
shuaimu May 21, 2026
2da8f66
rrr/reactor: wrap thread-local Reactor::clients_/dangling_ips_ in static
shuaimu May 21, 2026
5c81323
rrr/reactor: correct the comment on the accessor pattern
shuaimu May 21, 2026
f4c7ac2
rrr/reactor: annotate Reactor::clients/dangling_ips accessors @safe
shuaimu May 21, 2026
982f4d3
rrr/threading: Phase 3 — namespace @safe umbrellas + Pthread_* wrappers
shuaimu May 21, 2026
8f54ac1
rrr/reactor: Phase 4 — fiber context quarantine documentation + trivi…
shuaimu May 21, 2026
c1caaff
docs/srpc: tick rcc_rpc.h codegen rewrite — done in prior commits
shuaimu May 21, 2026
6dfd7eb
rrr/tests: add bench_marshal microbench + capture baseline
shuaimu May 21, 2026
7cf92cc
rrr: MarshalV2 prototype + bench harness; bump rusty-cpp for Vec fixes
shuaimu May 21, 2026
aeed22f
rrr: replace chunk-linked-list Marshal with Vec<uint8_t>+read_pos
shuaimu May 21, 2026
14ecb0c
docs/srpc: update Marshal byte-ops plan entry — labeling superseded
shuaimu May 21, 2026
05bec7b
docs/srpc: marshal perf post-mortem — the 5x drain speedup was mostly…
shuaimu May 21, 2026
71bae25
docs/srpc: marshal perf — calibrated A/B with leak-fixed chunk-list
shuaimu May 21, 2026
5f14288
docs/srpc: end-to-end RPC A/B for the three Marshal variants
shuaimu May 21, 2026
58446a2
rrr/client: flip 16 delegators / trivial wrappers from @unsafe to @safe
shuaimu May 21, 2026
1ab3214
rrr/client: flip ClientConnection class-level @unsafe → @safe
shuaimu May 21, 2026
4f827b9
rrr: rewire HashMap callers for Option<V&> return type
shuaimu May 22, 2026
b913732
rrr/client: flip 6 methods @unsafe → @safe enabled by HashMap API change
shuaimu May 22, 2026
4bce751
rrr: drop 6 @unsafe blocks around Weak<> copy/assignment
shuaimu May 22, 2026
5c082ad
rrr/client: const-ify connection lifecycle, drop 2 const_casts
shuaimu May 22, 2026
7738e2b
Merge branch 'mako-dev' into worktree-srpc
shuaimu May 22, 2026
c472b1a
ci: fix two more HashMap-API caller sites missed in the earlier rewire
shuaimu May 22, 2026
3ed7684
rrr/memdb: remove dead RefCounted base class + scrub stale doc comments
shuaimu May 22, 2026
b35c1d3
rrr/reactor: flip Fiber class-level @unsafe → @safe (asm stays unsafe)
shuaimu May 22, 2026
3c3151f
rrr/reactor: drop 5 stale @unsafe { Fiber::* } wraps now that Fiber i…
shuaimu May 22, 2026
3f7ea5a
rrr/rpc: flip Channel{Connection,Listener,Factory}Proxy → rusty::Box
shuaimu May 23, 2026
d6bf9cc
docs/rrr_safety_80pct_plan: tick Phase 2 channel-proxy item
shuaimu May 23, 2026
b7a4041
rrr/base: route time syscalls through rusty::sys::time
shuaimu May 23, 2026
0449448
docs/rrr_safety_80pct_plan: log rusty::sys::time partial-landing
shuaimu May 23, 2026
9bf498e
rrr: route remaining nanosleep call-sites through rusty::sys::time
shuaimu May 23, 2026
5018d21
rrr/base/threading: drop stale @unsafe overrides on Queue / SpinCondVar
shuaimu May 23, 2026
cc34e1a
rrr/base/logging: flip Log::set_level to @safe via Pthread_* wrappers
shuaimu May 23, 2026
963f5ca
rrr/reactor: flip IntEvent::set + QuorumEvent::vote_{yes,no} to @safe
shuaimu May 23, 2026
1c50a21
rrr/rpc/client: tighten three stale per-method / inline @unsafe blocks
shuaimu May 23, 2026
fbeb3ce
rrr/reactor: tighten 4 PollThreadWorker @unsafe markers
shuaimu May 23, 2026
22ef266
rrr/rpc/server: route Server::drain through rusty::sys::time
shuaimu May 23, 2026
e733537
rrr/rpc/tcp_channel: drop stale @unsafe on adapter accessors + local_…
shuaimu May 23, 2026
68bce01
rrr/rpc/tcp_channel: flip TcpListener::set_on_accept/set_on_error @safe
shuaimu May 23, 2026
23fc1e5
rrr/base/threading: drop stale @unsafe on ThreadPool::make / RunLater…
shuaimu May 23, 2026
97ef489
rrr: flip 4 more stale @unsafe markers on stub / container-only paths
shuaimu May 23, 2026
8d6e5db
rrr/reactor: drop stale "Fiber::finished" @unsafe blocks in Reactor::…
shuaimu May 23, 2026
b457f3c
rrr/reactor: flip Event::test() to @safe
shuaimu May 23, 2026
12cc371
rrr: drop stale inner @unsafe wraps around Vec::clear / SpinMutex /
shuaimu May 23, 2026
6d3950a
rrr: drop more stale inner @unsafe wraps (RefCell / Option / SpinMutex)
shuaimu May 23, 2026
feb26bb
rrr/rpc/client: drop 4 more stale inner @unsafe wraps
shuaimu May 23, 2026
ad271d3
rrr: route remaining chrono / Marshal-operator wraps through @safe paths
shuaimu May 23, 2026
c8c0395
rrr: drop 3 more stale inner @unsafe wraps (std::string + SpinMutex +…
shuaimu May 23, 2026
cb150ee
rrr/rpc/request_queue: flip RequestQueue::update_config to @safe
shuaimu May 23, 2026
4ab2623
rrr/reactor/fiber: drop stale @unsafe { Time::now } wrap
shuaimu May 23, 2026
05625b4
rrr/rpc/client: drop stale @unsafe wrap around reconnect_address_.emp…
shuaimu May 23, 2026
521812a
rrr/rpc/client: route monotonic_ms_now through rusty::sys::time
shuaimu May 23, 2026
5e0e338
rrr/misc/marshal: drop stale Vec::reserve @unsafe wraps
shuaimu May 23, 2026
afcd6f8
rrr/misc/marshal: drop stale Vec::push-loop @unsafe wrap
shuaimu May 23, 2026
25ddbaa
docs/rrr_safety_80pct_plan: log Phase 2 follow-on stale-annotation sweep
shuaimu May 23, 2026
7ea33de
rrr: route sysconf/getpid/times/sysinfo through rusty::sys::process
shuaimu May 23, 2026
a619b8a
rrr/rpc/utils: route get_host_name through rusty::sys::env::hostname
shuaimu May 23, 2026
1a1cae2
rrr/base: flip Rand::Rand to @safe via rusty::sys::pthread::current_i…
shuaimu May 23, 2026
796375e
docs/rrr_safety_80pct_plan: tick rusty::sys::* — 4 families shipped
shuaimu May 23, 2026
f6be7df
rrr/base/threading: delete dead ThreadPool / RunLater / SpinCondVar /…
shuaimu May 23, 2026
13ed448
rrr: delete dead NetInfo class + ServerConnection PollableProxy stubs
shuaimu May 23, 2026
edaa6f0
rrr/base/logging: replace pthread_mutex_t with rusty::sync::atomic::A…
shuaimu May 23, 2026
bb6bb21
ci: randomize paxos/raft replication ports with bind-probe at test init
shuaimu May 23, 2026
ddd9793
ci: cap paxos port base so heartbeat (port+10000) fits in 65535
shuaimu May 23, 2026
81de0bc
ci: randomize shard config for multi-shard single-process tests
shuaimu May 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,31 @@ endif()
# clang headers (e.g., clang 19 with __builtin_nondeterministic_value in AVX
# intrinsics), the checker must be linked against the matching libclang version
# to avoid "Fatal parsing errors" from unknown builtins.
#
# Production toolchain is Homebrew/Linuxbrew clang 21 (llvm@21). clang 22's
# libclang has a parse-time crash on first-time user-type template
# instantiations in module purview — see docs/dev/libclang22_parse_crash.md.
# Pick clang 21 first when present, then fall back to system clang.
if(NOT DEFINED ENV{LIBCLANG_PATH})
set(_LIBCLANG_CANDIDATES
# Linuxbrew clang 21 (current production)
"/home/users/shuai/.linuxbrew/opt/llvm@21/lib"
# macOS Homebrew clang 21
"/opt/homebrew/opt/llvm@21/lib"
"/usr/local/opt/llvm@21/lib"
)
foreach(_CAND ${_LIBCLANG_CANDIDATES})
if(EXISTS "${_CAND}/libclang.so" OR EXISTS "${_CAND}/libclang.dylib")
set(ENV{LIBCLANG_PATH} "${_CAND}")
message(STATUS "Auto-detected LIBCLANG_PATH=${_CAND} (Homebrew clang 21)")
break()
endif()
endforeach()
endif()
if(NOT DEFINED ENV{LIBCLANG_PATH})
# Search for the newest libclang, preferring higher versions
foreach(_CLANG_VER 19 18 17 16 15 14)
# Fall back to the newest system-installed libclang, preferring higher versions.
# We deliberately stop at 21 — see comment above re: clang 22 libclang crash.
foreach(_CLANG_VER 21 19 18 17 16 15 14)
set(_CLANG_LIB_DIR "/usr/lib/llvm-${_CLANG_VER}/lib")
if(EXISTS "${_CLANG_LIB_DIR}/libclang-${_CLANG_VER}.so" OR
EXISTS "${_CLANG_LIB_DIR}/libclang.so")
Expand Down Expand Up @@ -1558,6 +1580,15 @@ if(BUILD_TESTS)
target_link_libraries(test_marshal ${TEST_LINK_LIBS} ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread)
add_test(NAME test_marshal COMMAND test_marshal)

# Marshal Microbenchmark (no gtest — standalone main; prints ns/op).
# Measures the Vec<uint8_t>+read_pos Marshal — same harness used
# during the chunk-list → Vec rewrite (see
# docs/dev/marshal_perf_baseline.md).
add_executable(bench_marshal src/rrr/tests/bench_marshal.cc)
target_include_directories(bench_marshal PRIVATE ${TEST_INCLUDE_DIRS})
target_compile_options(bench_marshal PRIVATE ${TEST_COMPILE_OPTIONS})
target_link_libraries(bench_marshal ${RPC_TEST_LINK_LIBS} pthread)

# MakoClientService Unit Tests
add_executable(test_client_service tests/test_client_service.cc)
target_include_directories(test_client_service PRIVATE ${TEST_INCLUDE_DIRS} ${GTEST_INCLUDE_DIRS})
Expand Down
8 changes: 6 additions & 2 deletions bash/shard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,16 @@ if [ "$is_replicated" == "1" ]; then
replication_type_normalized="$(echo "$replication_type" | tr '[:upper:]' '[:lower:]')"

# Pick replication-specific config files.
# MAKO_PAXOS_CONFIG_DIR is set by the replication test wrappers when they
# materialize a randomized-port copy of the config into a tmp dir; fall back
# to the hardcoded path otherwise.
REPLICATION_CONFIG_DIR="${MAKO_PAXOS_CONFIG_DIR:-config/1leader_2followers}"
if [ "$replication_type_normalized" == "raft" ]; then
OCC_CONFIG="config/occ_raft.yml"
REPLICATION_CONFIG="config/1leader_2followers/raft${trd}_shardidx${shard}.yml"
REPLICATION_CONFIG="${REPLICATION_CONFIG_DIR}/raft${trd}_shardidx${shard}.yml"
else
OCC_CONFIG="config/occ_paxos.yml"
REPLICATION_CONFIG="config/1leader_2followers/paxos${trd}_shardidx${shard}.yml"
REPLICATION_CONFIG="${REPLICATION_CONFIG_DIR}/paxos${trd}_shardidx${shard}.yml"
fi

if [ ! -f "$REPLICATION_CONFIG" ]; then
Expand Down
228 changes: 228 additions & 0 deletions docs/dev/libclang22_parse_crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
# libclang 22 parse-time crash on first-time user-type template instantiation in module purview

## Status

- **Open** upstream LLVM bug — not yet reported (collected here for filing).
- **Production toolchain switched to clang 21.1.8** (Homebrew
`llvm@21`). clang 21 doesn't have the parse crash and also doesn't
have the clang-19 multi-attachment trap, so both server.cpp and
fiber_channel.cpp borrow-check with full-info findings. See
[`srpc_module_migration_plan.md`](srpc_module_migration_plan.md) for
the build invocation.
- **Workaround landed** (kept for the record / clang-22 fallback):
rusty-cpp's parser detects the libclang `Crash` error and retries
the parse with module args dropped (keeps `import std;` only). The
borrow check survives but loses cross-module callee resolution on
the affected TUs.
- Affected files in rrr (when running against clang-22 libclang):
`src/rrr/rpc/server.cpp`, `src/rrr/rpc/fiber_channel.cpp`.

## Summary

clang 22.1.5's libclang frontend crashes (returns the opaque error
`"Crash"` to `clang_parseTranslationUnit2`) when parsing certain
C++23 module purview translation units. The crash fires the moment
the parser closes the body of a function that performs a **first-time
template instantiation of a user-defined type** in module purview —
e.g. `rusty::make_box<ChannelFactoryProxy>(...)`.

`clang++ -fsyntax-only` with the exact same command-line flags
**compiles the file successfully**, so the bug is specific to
libclang's parse path, not clang's frontend in general.

The same source built with clang 19's libclang against
clang-19-generated PCMs parses cleanly with no recovery needed.

## Reproducer location

`src/rrr/rpc/server.cpp` lines 695-700:

```cpp
void set_channel_factory(ChannelFactoryProxy factory) {
if (!factory) return;
channel_factory_ = rusty::Some(
rusty::make_box<ChannelFactoryProxy>(std::move(factory)));
}
```

Bisection (clean truncations of `server.cpp` evaluated with our
borrow-check pipeline, libclang 22.1.5, all rrr module-graph PCMs
loaded):

| File length | Result |
|---:|---|
| 500 lines (no `set_channel_factory`) | clean parse |
| 600, 650, 675, 690, 695, 697, 698, 699 lines | clean parse |
| **700 lines** (closes `set_channel_factory` body) | **first-attempt `"Crash"`** |
| 705 lines | first-attempt `"Crash"` |
| 710 lines (closes the following methods) | clean parse again |

The crash is **parse-state-sensitive**: extending the file past the
trigger function with more method definitions can mask the crash.
This rules out "always crashes once X is parsed" and suggests an
intermediate parser state that recovers if the parse continues far
enough.

## Source-level characterization

- `ChannelFactoryProxy` is a typedef visible only in the current
module's purview (defined in `src/rrr/rpc/channel.cpp`, the
`rrr.channel` module).
- `rusty::make_box<T>` is `template<typename T, typename... Args>
Box<T> make_box(Args&&...)`, defined in `third-party/rusty-cpp/include/rusty/box.hpp`.
- Calling `rusty::make_box<ChannelFactoryProxy>(...)` from inside
`Server::set_channel_factory` triggers the **first** instantiation
of `rusty::make_box<ChannelFactoryProxy>` in the rrr.server module
purview.
- The GMF of `server.cpp` already does
`#include <rusty/rusty.hpp>` — the documented workaround for the
related clang-22 codegen crash on libc++ container templates
(see [`srpc_module_migration_plan.md`](srpc_module_migration_plan.md)).
That workaround pre-instantiates std::vector/std::deque/... but
doesn't reach user-defined types like
`rusty::Box<ChannelFactoryProxy>`.

## clang-19 vs clang-21 vs clang-22 comparison (definitive)

Built `rrr` with clang 19 in `build_clang19/`, producing matching
clang-19 PCMs for every module except `rrr.server` (which clang-19
itself can't compile due to a separate, documented multi-attachment
bug on `rusty::HashMap::operator()`). Built with clang 21 in
`build_clang21/`, which is the new production toolchain.

| Setup | server.cpp | fiber_channel.cpp |
|---|---|---|
| libclang 22 + clang-22 PCMs (former production) | First-attempt **Crash**; recovers via std-only retry; degraded analysis | First-attempt **Crash**; recovers via std-only retry; degraded analysis |
| **libclang 21 + clang-21 PCMs (current production)** | **Clean parse**, full-info findings | **Clean parse**, full-info findings |
| libclang 19 + clang-19 PCMs (matched, see caveat) | **Clean parse**, 6 full-info findings | **Clean parse**, 3 full-info findings |
| libclang 19 + clang-22 PCMs (mismatched) | PCM version-mismatch error; recovers cleanly | Same |

Combined with the fact that `clang++ -fsyntax-only` compiles the
source without issue, this is conclusively a **libclang-22
regression** introduced between clang 19 and clang 22, and fixed (or
never introduced) on the clang-21 branch.

## Why we use clang 21 (and not clang 19 or clang 22)

clang 19 has its own showstopper: `rusty::HashMap<K, V>::operator()`
gets multi-attached across module boundaries (instantiations from
`rrr.reactor` clash with the same instantiation in `rrr.server`),
which clang 21/22 explicitly fixed. We hit this when trying to
produce matching clang-19 PCMs:

```
rusty-cpp/include/rusty/hashmap.hpp:77:12: error: declaration
'operator()' attached to named module 'rrr.reactor' can't be
attached to other modules
```

clang 22 has the libclang parse-crash regression documented in this
file.

clang 21 has neither problem. It is the sweet spot: stricter compile
checks than clang 19 (it caught the duplicate `class Client`
forward-decl in `rpc/load_balancer.cpp` that clang 22 was silently
accepting — see commit `df2388f6`), clean parse on the borrow-check
pipeline, and full-info findings across all 45 module units.

### Source fixups required for the clang-21 switch

Two small source changes were needed to ride on clang 21:

1. `rpc/load_balancer.cpp` — drop the GMF forward-decl `namespace
rrr { class Client; }`. clang 21 (correctly) rejects re-declaring a
class that's fully declared in another imported module's purview.
Commit `df2388f6`.

2. `reactor/reactor.cpp` — convert class-static `thread_local`
members (`Reactor::sp_reactor_th_`, `Reactor::sp_disk_reactor_th_`,
`Reactor::sp_running_fiber_th_`, `PollThreadWorker::current_worker_`)
to `static inline thread_local`. clang 21 emits the module-attached
TLS storage as a strong external in every TU that uses it via an
inline accessor (e.g. `is_on_poll_thread()`), producing
duplicate-definition linker errors at executable-link time:

```
multiple definition of `TLS init function for
rrr::Reactor@rrr.reactor::sp_reactor_th_';
```

`inline` puts the symbol in vague linkage so the linker dedupes.
clang 22 happened to keep these in vague linkage already; clang 21
needs the `inline` to be explicit. Commit `8f62ed80`.

## Possible upstream classification

- Likely a regression in clang 22's **template-instantiation
serialization** within libclang's incomplete-TU parsing mode (the
driver pipeline does not exhibit it because it follows a different
codegen path).
- Related bug class to the documented clang-22 codegen crash
("instantiating libc++ container templates ... for the first time
crashes EmitScalarExpr inside EmitReturnStmt/EmitIfStmt") — but
that one is in codegen (`-c`) and only affects libc++ types, while
this one is in libclang parse and affects user-defined types too.

## Minimal-shape repro outline (for upstream filing)

A reduced reproducer would look approximately like:

```cpp
// File: repro.cpp
module;
#include <rusty/rusty.hpp> // workaround pre-instantiation for libc++
export module repro;
import std;
import other_module; // brings UserType into scope

export namespace repro {

class UserHolder {
public:
rusty::Option<rusty::Box<UserType>> slot_;

void set(UserType v) {
// First instantiation of rusty::make_box<UserType> in this
// module's purview. libclang-22 crashes when parsing the
// closing `}` of this function.
slot_ = rusty::Some(rusty::make_box<UserType>(std::move(v)));
}
};

}
```

Building the dependency PCMs and running:

```
clang++ -fsyntax-only -std=gnu++23 -stdlib=libc++ -x c++-module \
-fmodule-file=std=std.pcm -fmodule-file=other_module=other.pcm \
-fparse-all-comments repro.cpp
```

succeeds. Invoking libclang-22's parse API (`clang_parseTranslationUnit2`)
with the same arguments returns `CXError_Crashed`.

We have not yet validated this exact minimal shape against a stock
clang 22 install; the rrr-internal reproducer is concrete and
exercises the path.

## Filing checklist (when ready)

- [ ] Build a self-contained minimum reproducer (no rusty-cpp dep —
use raw `std::optional<std::unique_ptr<T>>` shape).
- [ ] Verify the reproducer fires on stock clang 22.1.5 and check
whether it has been fixed on trunk.
- [ ] File at https://github.com/llvm/llvm-project/issues with the
"clang:frontend" and "modules" labels.
- [ ] Cross-link the upstream issue here and in
[`srpc_module_migration_plan.md`](srpc_module_migration_plan.md).

## Cross-references

- `third-party/rusty-cpp/src/parser/mod.rs` — Crash-recovery
fallback in `parse_cpp_file_with_includes_defines_and_args`.
- `third-party/rusty-cpp/src/parser/header_cache.rs` — import-chasing
for cross-module annotation discovery (related fix).
- [`srpc_module_migration_plan.md`](srpc_module_migration_plan.md)
— broader migration narrative and the related codegen crash.
Loading
Loading