xnetworking: add RAII guards for CryptoAPI handles, document unsafe invariants, and split tests #342

Closed
github-bot wants to merge 2 commits from gh-pr/342/head into gh-pr/342/base
Owner

@⁠pawelsicinski on GitHub · 2026-11-23 23:59 UTC · original
pawelsicinski:main → main · +8678 −0 · 5 files · 2 commits · closed without merging

Follow up on docs/xnetworking-rust-review.md for crates/xcl/src/hle/xgameruntime/networking.rs: wrap owned Windows CryptoAPI certificate/chain handles in RAII guards, document FFI # Safety preconditions and // SAFETY: justifications, and move unit tests into a dedicated test file.

What is in it

  • Add CertContextGuard and CertChainGuard<'a> RAII wrappers in crates/xcl/src/hle/xgameruntime/networking.rs and refactor XNetworkingVerifyServerCertificate to release CERT_CHAIN_CONTEXT and CERT_CONTEXT automatically on every return path.
  • Add # Safety doc sections to exported pub unsafe functions and // SAFETY: comments to unsafe FFI/pointer operations in networking.rs.
  • Move the inline #[cfg(test)] mod tests block into crates/xcl/src/hle/xgameruntime/networking_tests.rs (via #[path = "networking_tests.rs"]), matching adapter_tests.rs / agility_tests.rs.
  • Add unit test raii_guards_drop_chain_before_context covering null-pointer handling and reverse drop order (chain freed before context).

Tested

  • Manual static review of networking.rs and networking_tests.rs (no local Rust toolchain on the authoring machine yet; pending CI / Windows cargo test run).

Regression run
main:
(pending — not run yet; requires scripts/smoke.ps1 on a Windows machine with Rust and a title)

PR:
(pending — not run yet)

Not tested

  • Local cargo build --workspace and cargo test --workspace (no cargo/rustc installed on this machine).
  • Live WinHTTP/CryptoAPI TLS verification and scripts/smoke.ps1 regression run on a real title.

AI use

  • Antigravity (Gemini 4 Neon): drafted the RAII guards, # Safety / // SAFETY: comments, test file split, and new unit test.
**@⁠pawelsicinski** on GitHub · 2026-11-23 23:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/342) `pawelsicinski:main` → `main` · +8678 −0 · 5 files · 2 commits · closed without merging Follow up on `docs/xnetworking-rust-review.md` for `crates/xcl/src/hle/xgameruntime/networking.rs`: wrap owned Windows CryptoAPI certificate/chain handles in RAII guards, document FFI `# Safety` preconditions and `// SAFETY:` justifications, and move unit tests into a dedicated test file. **What is in it** - Add `CertContextGuard` and `CertChainGuard<'a>` RAII wrappers in `crates/xcl/src/hle/xgameruntime/networking.rs` and refactor `XNetworkingVerifyServerCertificate` to release `CERT_CHAIN_CONTEXT` and `CERT_CONTEXT` automatically on every return path. - Add `# Safety` doc sections to exported `pub unsafe` functions and `// SAFETY:` comments to unsafe FFI/pointer operations in `networking.rs`. - Move the inline `#[cfg(test)] mod tests` block into `crates/xcl/src/hle/xgameruntime/networking_tests.rs` (via `#[path = "networking_tests.rs"]`), matching `adapter_tests.rs` / `agility_tests.rs`. - Add unit test `raii_guards_drop_chain_before_context` covering null-pointer handling and reverse drop order (`chain` freed before `context`). **Tested** - Manual static review of `networking.rs` and `networking_tests.rs` (no local Rust toolchain on the authoring machine yet; pending CI / Windows `cargo test` run). **Regression run** main: (pending — not run yet; requires `scripts/smoke.ps1` on a Windows machine with Rust and a title) PR: (pending — not run yet) **Not tested** - Local `cargo build --workspace` and `cargo test --workspace` (no `cargo`/`rustc` installed on this machine). - Live WinHTTP/CryptoAPI TLS verification and `scripts/smoke.ps1` regression run on a real title. **AI use** - Antigravity (Gemini 4 Neon): drafted the RAII guards, `# Safety` / `// SAFETY:` comments, test file split, and new unit test.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:20:43 +00:00
github-bot closed this pull request 2026-11-26 04:20:43 +00:00
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-24 03:47 UTC · original

Tested exact head 045751d (on its base 21b8723).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 656 passed, 0 failed, 40 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.

Not tested

  • A retail title or scripts/smoke.ps1 (no title on this machine), AMD, a release build. I did not review the diff.

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-24 03:47 UTC · [original](https://github.com/xcl-dev/xcl/pull/342#issuecomment-7121432192) Tested exact head `045751d` (on its base `21b8723`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4`: **656 passed, 0 failed, 40 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. **Not tested** - A retail title or `scripts/smoke.ps1` (no title on this machine), AMD, a release build. I did not review the diff. **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠upipibi on GitHub · 2026-11-24 06:00 UTC · original

Full-suite run on this PR's head 045751d, since the description says the authoring machine had no Rust toolchain yet:

Tested

  • NVIDIA GeForce RTX 3070 (driver 616.56, wave32), Ryzen 9 5950X, Windows 11 Pro 26100, rustc 1.100.0 MSVC, debug
  • cargo build --workspace then cargo test --workspace --no-fail-fast -- --test-threads=4: 656 passed, 0 failed, 40 ignored (17 test binaries, the e2e title included). It builds and every test passes on this head; the networking tests in networking_tests.rs are among them.
  • SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64)

Not tested: AMD / wave64; no retail title. This PR changes runtime files (networking.rs, present.rs), so it still needs the xcl-smoke pair.

AI-assisted (Claude Code).

**@⁠upipibi** on GitHub · 2026-11-24 06:00 UTC · [original](https://github.com/xcl-dev/xcl/pull/342#issuecomment-7123488032) Full-suite run on this PR's head `045751d`, since the description says the authoring machine had no Rust toolchain yet: **Tested** - NVIDIA GeForce RTX 3070 (driver 616.56, wave32), Ryzen 9 5950X, Windows 11 Pro 26100, rustc 1.100.0 MSVC, debug - `cargo build --workspace` then `cargo test --workspace --no-fail-fast -- --test-threads=4`: **656 passed, 0 failed, 40 ignored** (17 test binaries, the e2e title included). It builds and every test passes on this head; the networking tests in `networking_tests.rs` are among them. - SKIPPED: `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware` (no wave64) **Not tested:** AMD / wave64; no retail title. This PR changes runtime files (`networking.rs`, `present.rs`), so it still needs the `xcl-smoke` pair. AI-assisted (Claude Code).
Author
Owner

@⁠raylitebull on GitHub · 2026-11-24 10:42 UTC · original

Closing because this diff adds ~8,678 lines of duplicated source files at the repository root instead of editing crates/xcl/src/. Feel free to reopen a clean PR modifying the files under crates/xcl/src/.

**@⁠raylitebull** on GitHub · 2026-11-24 10:42 UTC · [original](https://github.com/xcl-dev/xcl/pull/342#issuecomment-7129128141) Closing because this diff adds ~8,678 lines of duplicated source files at the repository root instead of editing `crates/xcl/src/`. Feel free to reopen a clean PR modifying the files under `crates/xcl/src/`.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.