Skip to content

Run guard page crash tests on Windows - #1899

Merged
ludfjig merged 1 commit into
hyperlight-dev:mainfrom
DanielTangnes:windows-guard-page-tests
Oct 14, 2026
Merged

ludfjig merged 1 commit into
hyperlight-dev:mainfrom
DanielTangnes:windows-guard-page-tests

Conversation

@DanielTangnes

Copy link
Copy Markdown
Contributor

Fixes #1508

guard_page_crash_test (read/write/exec on the leading guard page of ExclusiveSharedMemory) runs on Linux and Windows. It uses the subprocess approach from #1498.

What changed:

  • test_path, run_guard_page_subprocess and killed_by_access_violation live in a small guard_page_subprocess test module that both shims use. The bodies are unchanged, so git diff --color-moved shows them as a move.
  • The three tests print reached_guard / survived_guard around the bad access. The shim reruns the current test binary with --ignored --exact for each one.
  • The module is gated on all(not(miri), any(target_os = "linux", windows)).
  • Removed the signal-hook-registry dev-dependency. The SIGSEGV hook in these tests was its only user.

A side effect on Linux: the old shim spawned cargo test without --profile, so under just test release it rebuilt and checked a debug binary. Rerunning current_exe() keeps the child on the parent's profile and skips the extra build.

I left macOS out to match the issue. from_file_tests already runs there, but I couldn't check which signal the exec case raises on Apple silicon. Happy to widen the gate if you want it.

Test-only change, so no changelog entry.

Testing (Linux x86_64, KVM host):

  • cargo test -p hyperlight-host --lib -- mem::shared_mem::tests: 28 passed, 5 ignored
  • cargo test -p hyperlight-host --profile=release --lib -- guard_page: both shims pass
  • Sanity check: with the leading guard page left PROT_READ | PROT_WRITE, the shim fails with survived=true (reverted afterwards)
  • rustfmt and clippy: no findings in shared_mem.rs. I ran these with a 1.98 toolchain rather than the pinned 1.94 and nightly rustfmt, so CI is the real check.
  • Not run locally: Windows, macOS, just miri-tests, full just test. The Windows run comes from CI.

Could a maintainer add kind/enhancement? I can't set labels from a fork.

🤖 Generated with Claude Code

@DanielTangnes
DanielTangnes marked this pull request as ready for review October 7, 2026 21:11
Copilot AI balanced review requested due to automatic review settings October 7, 2026 21:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The subprocess checks, platform gates, and dependency cleanup are consistent and complete.

0 open findings

What changed in this PR

Enables ExclusiveSharedMemory guard page crash tests on Windows using isolated test subprocesses.

Changes:

  • Reuses a shared subprocess test harness.
  • Detects Linux signals and Windows access violations.
  • Removes the unused direct signal hook dependency.
File Description
src/​hyperlight_host/​src/​mem/​shared_mem.rs Adds cross-platform guard page crash testing.
src/​hyperlight_host/​Cargo.toml Removes the unused dev dependency.
Cargo.lock Removes the direct dependency edge.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@ludfjig ludfjig added the kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. label Oct 12, 2026
ludfjig
ludfjig previously approved these changes Oct 12, 2026

@ludfjig ludfjig left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks a lot for this, this is great!

@hyperlight-gh-bot

This comment has been minimized.

@ludfjig

ludfjig commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

@DanielTangnes looks like CI is failing. If you could address the formatting and then rebase I'd be happy to merge this :)

The read, write and exec guard page tests rerun the test binary with
--exact and check its exit status using the helpers from the from_file
guard tests. That works on Windows, where the SIGSEGV hook can't, and
keeps the child on the same build profile as the parent.

Drop the signal-hook-registry dev-dependency. These tests were its
only user.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011CnFoNrC4zWqRUqoeDzS6P
Signed-off-by: danieltangnes <danieltangnes1@gmail.com>
@DanielTangnes

Copy link
Copy Markdown
Contributor Author

@ludfjig Should be good to go now :)

@hyperlight-gh-bot

Copy link
Copy Markdown

Benchmark Results

Measured commit: 7bd0b1aa69e1
Baseline commit: ad05110e17bf

kvm / amd (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 747.90 ns (➖ 1.01x faster)
vec_bytes 582.51 ns (➖ 1.00x faster)
372.05 µs (➖ 1.00x slower)

payload_allocation

slot_pool_segmented
262144 522.20 ns (➖ 1.00x faster)
65536 141.63 ns (➖ 1.03x faster)

sandboxes

create_initialized_and_drop
medium 81.81 ms (➖ 1.01x slower)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
7.73 ns (➖ 1.00x slower) 7.92 ns (➖ 1.02x slower) 8.03 ns (➖ 1.04x slower)

snapshot_files

load_snapshot_unverified
small 80.04 µs (➖ 1.15x faster)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 7.66 µs (➖ 1.13x faster) 7.02 µs (➖ 1.03x faster)
65536 2.09 µs (➖ 1.08x slower) 1.95 µs (➖ 1.07x faster)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 6.29 µs (➖ 1.05x faster) 6.35 µs (➖ 1.00x faster)
8192 1.07 µs (➖ 1.02x faster) 1.08 µs (➖ 1.03x slower)
262144 27.44 µs (➖ 1.00x faster)
kvm / intel (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 665.97 ns (➖ 1.01x faster)
vec_bytes 521.60 ns (➖ 1.03x slower)
654.73 µs (➖ 1.00x faster)

payload_allocation

slot_pool_segmented
262144 497.06 ns (➖ 1.01x faster)
65536 134.32 ns (➖ 1.00x faster)

sandboxes

create_initialized_and_drop
medium 75.33 ms (➖ 1.04x faster)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
6.93 ns (➖ 1.02x faster) 6.85 ns (➖ 1.00x faster) 6.92 ns (➖ 1.01x faster)

snapshot_files

load_snapshot_unverified
small 46.08 µs (➖ 1.01x slower)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 7.52 µs (➖ 1.00x slower) 7.54 µs (➖ 1.00x faster)
65536 2.13 µs (➖ 1.00x faster) 2.14 µs (➖ 1.02x slower)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 7.10 µs (➖ 1.01x faster) 7.09 µs (➖ 1.02x faster)
8192 759.78 ns (➖ 1.03x faster) 808.14 ns (➖ 1.08x slower)
262144 30.94 µs (➖ 1.02x slower)
mshv3 / amd (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 946.82 ns (➖ 1.02x faster)
vec_bytes 713.64 ns (➖ 1.01x faster)
320.70 µs (➖ 1.00x faster)

payload_allocation

slot_pool_segmented
262144 674.63 ns (➖ 1.00x slower)
65536 182.62 ns (➖ 1.02x faster)

sandboxes

create_initialized_and_drop
medium 58.08 ms (➖ 1.01x slower)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
9.92 ns (➖ 1.01x faster) 9.96 ns (➖ 1.01x faster) 9.96 ns (➖ 1.00x faster)

snapshot_files

load_snapshot_unverified
small 87.66 µs (➖ 1.02x slower)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 9.56 µs (➖ 1.01x slower) 9.00 µs (➖ 1.05x faster)
65536 2.64 µs (➖ 1.02x faster) 2.48 µs (➖ 1.00x slower)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 8.00 µs (➖ 1.03x faster) 8.10 µs (➖ 1.01x faster)
8192 1.35 µs (➖ 1.00x slower) 1.35 µs (➖ 1.01x faster)
262144 34.89 µs (➖ 1.01x faster)
mshv3 / intel (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 902.73 ns (➖ 1.00x slower)
vec_bytes 676.73 ns (➖ 1.03x slower)
639.97 µs (➖ 1.14x faster)

payload_allocation

slot_pool_segmented
262144 646.18 ns (➖ 1.01x slower)
65536 169.14 ns (➖ 1.02x slower)

sandboxes

create_initialized_and_drop
medium 75.84 ms (➖ 1.07x slower)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
9.72 ns (➖ 1.01x slower) 9.46 ns (➖ 1.00x slower) 9.17 ns (➖ 1.00x slower)

snapshot_files

load_snapshot_unverified
small 46.35 µs (➖ 1.00x slower)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 7.98 µs (➖ 1.01x slower) 7.93 µs (➖ 1.00x slower)
65536 2.27 µs (➖ 1.00x slower) 2.26 µs (➖ 1.01x slower)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 7.64 µs (➖ 1.01x slower) 7.53 µs (➖ 1.01x faster)
8192 945.59 ns (➖ 1.01x faster) 926.64 ns (➖ 1.01x slower)
262144 39.76 µs (➖ 1.03x faster)
hyperv-ws2025 / amd (Windows) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 1.17 µs (➖ 1.12x faster)
vec_bytes 777.11 ns (➖ 1.03x faster)
2.22 ms (➖ 1.02x slower)

payload_allocation

slot_pool_segmented
262144 806.03 ns (➖ 1.02x slower)
65536 239.88 ns (➖ 1.04x slower)

sandboxes

create_initialized_and_drop
medium 103.60 ms (➖ 1.03x slower)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
10.14 ns (➖ 1.05x faster) 10.17 ns (➖ 1.02x faster) 10.35 ns (➖ 1.03x slower)

snapshot_files

load_snapshot_unverified
small 794.52 µs (➖ 1.03x slower)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 9.46 µs (➖ 1.01x faster) 9.34 µs (➖ 1.02x slower)
65536 2.42 µs (➖ 1.01x slower) 2.39 µs (➖ 1.02x slower)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 9.11 µs (➖ 1.02x faster) 9.05 µs (➖ 1.01x faster)
8192 1.31 µs (➖ 1.04x faster) 1.29 µs (➖ 1.00x faster)
262144 48.44 µs (➖ 1.26x slower)
hyperv-ws2025 / intel (Windows) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 1.22 µs (➖ 1.01x faster)
vec_bytes 795.06 ns (➖ 1.02x slower)
2.96 ms (➖ 1.05x faster)

payload_allocation

slot_pool_segmented
262144 729.71 ns (➖ 1.02x faster)
65536 213.13 ns (➖ 1.16x faster)

sandboxes

create_initialized_and_drop
medium 101.06 ms (➖ 1.18x faster)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
10.07 ns (➖ 1.09x faster) 9.96 ns (➖ 1.01x faster) 10.03 ns (➖ 1.01x slower)

snapshot_files

load_snapshot_unverified
small 486.19 µs (➖ 1.26x faster)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 7.85 µs (➖ 1.03x slower) 7.82 µs (➖ 1.01x slower)
65536 2.48 µs (➖ 1.07x slower) 2.39 µs (➖ 1.02x slower)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 8.45 µs (➖ 1.03x faster) 8.48 µs (➖ 1.03x faster)
8192 1.14 µs (➖ 1.14x faster) 1.09 µs (➖ 1.02x faster)
262144 40.14 µs (➖ 1.14x faster)

Reported by cargo ci bench-report --candidate run:38528262223 --config-file bench_report.toml.

@ludfjig ludfjig left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!!

@ludfjig
ludfjig merged commit b8783e8 into hyperlight-dev:main Oct 14, 2026
120 of 122 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement For PRs adding features, improving functionality, docs, tests, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable all memory guard page tests on windows

3 participants