Skip to content

Add slice op soundness tests#220

Merged
Shnatsel merged 2 commits into
linebender:mainfrom
Shnatsel:slice-soundness-tests
May 20, 2026
Merged

Add slice op soundness tests#220
Shnatsel merged 2 commits into
linebender:mainfrom
Shnatsel:slice-soundness-tests

Conversation

@Shnatsel
Copy link
Copy Markdown
Contributor

The vast majority of our operations accept fixed-size inputs with the lengths encoded in type system, so they are pretty hard to mess up. We also have Address Sanitizer on CI verifying that all the raw intrinsics actually stick to those sizes.

The only exception are from_slice/store_slice APIs, which accept variable-length slices. This PR adds tests verifying that slices that are too short are correctly rejected.

@Shnatsel Shnatsel enabled auto-merge May 19, 2026 13:53
@LaurenzV
Copy link
Copy Markdown
Collaborator

Instead of doing this unwinding thing, can we not simply change the simd_test macro to accept an additional attribute should_panic that propagates it to the test?

@Shnatsel
Copy link
Copy Markdown
Contributor Author

Shnatsel commented May 19, 2026

We could, but that makes the proc macro even more complex and magical, and I'm trying to keep things simple and stupid to make them easier to maintain in the long run. This already uses a macro to reduce duplication so I felt I've already spent all the complexity budget.

Plus I didn't expect this to be used often (there are literally two methods where this is even needed) so I didn't think it was worth complicating the common path for the sake of this.

@Shnatsel
Copy link
Copy Markdown
Contributor Author

I've heard that cargo nextest might be able to run #[should_panic] tests on WASM which doesn't have unwinding, since it runs each test in a separate process. But turns out that's not true. Instead of running the test and checking if it terminated, cargo nextest simply skips #[should_panic] tests on targets without unwinding.

@Shnatsel Shnatsel added this pull request to the merge queue May 20, 2026
Merged via the queue into linebender:main with commit cd2828d May 20, 2026
22 checks passed
@Shnatsel Shnatsel deleted the slice-soundness-tests branch May 20, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants