Skip to content

Run guard page crash tests on Windows - #1899

Open
DanielTangnes wants to merge 1 commit into
hyperlight-dev:mainfrom
DanielTangnes:windows-guard-page-tests
Open

DanielTangnes wants to merge 1 commit into
hyperlight-dev:mainfrom
DanielTangnes:windows-guard-page-tests

Conversation

@DanielTangnes

Copy link
Copy Markdown

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

Copy link
Copy Markdown

Benchmark Results

Measured commit: edca0d5cb1c6
Baseline commit: 5ddb37af894e

kvm / amd (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 791.84 ns (➖ 1.04x slower)
vec_bytes 586.78 ns (➖ 1.00x slower)
375.35 µs (➖ 1.00x slower)

payload_allocation

slot_pool_segmented
262144 524.65 ns (➖ 1.07x faster)
65536 141.62 ns (➖ 1.02x faster)

sandboxes

create_initialized_and_drop
medium 78.58 ms (➖ 1.01x faster)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
7.74 ns (➖ 1.00x faster) 7.75 ns (➖ 1.00x faster) 7.89 ns (➖ 1.06x faster)

snapshot_files

load_snapshot_unverified
small 92.10 µs (➖ 1.02x faster)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 7.20 µs (➖ 1.01x faster) 7.16 µs (➖ 1.05x faster)
65536 2.06 µs (➖ 1.02x faster) 1.94 µs (➖ 1.00x slower)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 6.29 µs (➖ 1.01x slower) 6.25 µs (➖ 1.02x faster)
8192 1.06 µs (➖ 1.03x slower) 1.06 µs (➖ 1.01x faster)
262144 27.17 µs (➖ 1.00x slower)
kvm / intel (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 826.45 ns (➖ 1.18x slower)
vec_bytes 607.69 ns (➖ 1.17x slower)
762.40 µs (➖ 1.17x slower)

payload_allocation

slot_pool_segmented
262144 585.31 ns (➖ 1.16x slower)
65536 157.21 ns (➖ 1.14x slower)

sandboxes

create_initialized_and_drop
medium 81.59 ms (➖ 1.14x slower)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
8.12 ns (➖ 1.17x slower) 8.00 ns (➖ 1.16x slower) 8.09 ns (➖ 1.16x slower)

snapshot_files

load_snapshot_unverified
small 53.13 µs (➖ 1.20x slower)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 8.63 µs (➖ 1.14x slower) 8.72 µs (➖ 1.16x slower)
65536 2.44 µs (➖ 1.16x slower) 2.54 µs (➖ 1.17x slower)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 8.09 µs (➖ 1.15x slower) 8.32 µs (➖ 1.17x slower)
8192 846.98 ns (➖ 1.18x slower) 856.57 ns (➖ 1.18x slower)
262144 33.40 µs (➖ 1.14x slower)
mshv3 / amd (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 951.72 ns (➖ 1.00x slower)
vec_bytes 715.24 ns (➖ 1.00x slower)
294.60 µs (➖ 1.24x faster)

payload_allocation

slot_pool_segmented
262144 734.61 ns (➖ 1.01x slower)
65536 192.25 ns (➖ 1.01x slower)

sandboxes

create_initialized_and_drop
medium 62.27 ms (➖ 1.09x slower)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
9.74 ns (➖ 1.00x slower) 9.73 ns (➖ 1.00x slower) 9.68 ns (➖ 1.00x faster)

snapshot_files

load_snapshot_unverified
small 88.21 µs (➖ 1.06x slower)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 9.04 µs (➖ 1.06x faster) 8.89 µs (➖ 1.09x faster)
65536 2.25 µs (➖ 1.07x faster) 2.24 µs (➖ 1.09x faster)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 8.18 µs (➖ 1.05x faster) 8.43 µs (➖ 1.05x slower)
8192 1.27 µs (➖ 1.02x faster) 1.32 µs (➖ 1.02x faster)
262144 36.52 µ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 930.94 ns (➖ 1.00x faster)
vec_bytes 677.75 ns (➖ 1.01x slower)
695.70 µs (➖ 1.00x faster)

payload_allocation

slot_pool_segmented
262144 621.56 ns (➖ 1.10x faster)
65536 169.98 ns (➖ 1.00x faster)

sandboxes

create_initialized_and_drop
medium 64.20 ms (➖ 1.00x faster)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
9.79 ns (➖ 1.00x faster) 8.76 ns (➖ 1.00x faster) 8.78 ns (➖ 1.00x slower)

snapshot_files

load_snapshot_unverified
small 43.96 µs (➖ 1.03x faster)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 7.80 µs (➖ 1.01x faster) 7.75 µs (➖ 1.00x faster)
65536 2.25 µs (➖ 1.01x slower) 2.27 µs (➖ 1.01x faster)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 7.56 µs (➖ 1.00x slower) 7.56 µs (➖ 1.01x faster)
8192 857.88 ns (➖ 1.00x faster) 865.31 ns (➖ 1.03x faster)
262144 38.18 µs (➖ 1.07x slower)
hyperv-ws2025 / amd (Windows) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 1.36 µs (➖ 1.30x slower)
vec_bytes 756.70 ns (➖ 1.22x faster)
2.38 ms (➖ 1.08x slower)

payload_allocation

slot_pool_segmented
262144 784.26 ns (➖ 1.01x faster)
65536 230.51 ns (➖ 1.00x faster)

sandboxes

create_initialized_and_drop
medium 108.92 ms (➖ 1.28x slower)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
12.46 ns (➖ 1.14x slower) 11.37 ns (➖ 1.07x slower) 10.57 ns (➖ 1.06x slower)

snapshot_files

load_snapshot_unverified
small 780.12 µs (➖ 1.14x faster)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 8.68 µs (➖ 1.08x faster) 8.69 µs (➖ 1.24x faster)
65536 2.54 µs (➖ 1.05x slower) 2.56 µs (➖ 1.08x slower)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 8.93 µs (➖ 1.08x slower) 8.98 µs (➖ 1.01x slower)
8192 1.43 µs (➖ 1.05x slower) 1.36 µs (➖ 1.05x slower)
262144 46.21 µs (➖ 1.08x 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.18x slower)
vec_bytes 836.70 ns (➖ 1.10x slower)
3.81 ms (➖ 1.21x slower)

payload_allocation

slot_pool_segmented
262144 742.87 ns (➖ 1.38x faster)
65536 211.29 ns (➖ 1.45x faster)

sandboxes

create_initialized_and_drop
medium 108.85 ms (➖ 1.00x slower)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
10.05 ns (➖ 1.31x faster) 10.62 ns (➖ 1.38x faster) 10.03 ns (➖ 1.28x faster)

snapshot_files

load_snapshot_unverified
small 621.14 µs (➖ 1.07x slower)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 7.79 µs (➖ 1.02x slower) 7.83 µs (➖ 1.03x faster)
65536 2.33 µs (➖ 1.02x slower) 2.37 µs (➖ 1.01x slower)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 8.72 µs (➖ 1.00x slower) 9.29 µs (➖ 1.07x slower)
8192 1.14 µs (➖ 1.09x faster) 1.22 µs (➖ 1.08x slower)
262144 59.56 µs (➖ 1.42x slower)

Reported by cargo ci bench-report --candidate run:37686822795 --baseline run:37707245718 --config-file bench_report.toml.

@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
Author

@ludfjig Should be good to go now :)

This branch has not been deployed

No deployments
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