Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 5, 2025

This unsafe memory operation crate had only indirect coverage via the sparse_mmap fuzzer. This adds direct fuzzing for its public APIs.

Changes

  • fast_memcpy fuzzer: Tests memcpy with separate buffers and memmove with overlapping regions, validated against reference implementation

  • Helper function: Extracted safe_copy_length() to ensure consistent bounds checking across operations

The fuzzer follows existing patterns from other fuzz targets in the repository (e.g., ucs2, sparse_mmap).

Example

The fast_memcpy fuzzer validates correctness:

// memcpy: separate buffers (undefined behavior if overlapping)
unsafe { fast_memcpy::memcpy(dest, src, len) };
assert_eq!(dest[..len], src[..len]);

// memmove: same buffer, validate against reference
unsafe { fast_memcpy::memmove(buf.add(dest_off), buf.add(src_off), len) };
assert_eq!(buf, reference_buf);  // reference computed with copy_within

Fixes #2348

Original prompt

This section details on the original issue you should resolve

<issue_title>fuzz trycopy and fast_memcpy</issue_title>
<issue_description>These crates already have significant usage by the rest of the codebase, and trycopy has some fuzz coverage provided by the sparse_mmap fuzzer, but we should fuzz these unsafe crates directly.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add fuzz testing for trycopy and fast_memcpy Add fuzzing for trycopy and fast_memcpy Nov 5, 2025
Copilot AI requested a review from benhillis November 5, 2025 19:22
Copilot finished work on behalf of benhillis November 5, 2025 19:22
@benhillis
Copy link
Member

This might be above Copilot's paygrade, I'm just curious what it will come up with.

@smmalis37
Copy link
Contributor

Probably want to try doing them separately so it doesn't get confused.

@benhillis
Copy link
Member

benhillis commented Nov 6, 2025

@copilot - let's make this task more simple. Just implement fuzzing for fast_memcpy. Look at other examples of fuzzing done in the repo to make sure you are using a similar approach.

Copy link
Contributor Author

Copilot AI commented Nov 6, 2025

@copilot - let's make this task more simple. Just implement fuzzing for fast_memcpy. Look at other examples of fuzzing done in the repo to make sure you are using a similar approach.

Simplified the PR to only include fast_memcpy fuzzing. Removed the trycopy fuzzer and kept the implementation consistent with other fuzzers in the repo (like ucs2 and sparse_mmap). The fuzzer tests both memcpy (with separate buffers) and memmove (with overlapping regions), validated against a reference implementation. Commit: 08b5f97

Copilot AI changed the title Add fuzzing for trycopy and fast_memcpy Add fuzzing for fast_memcpy Nov 6, 2025
Copilot finished work on behalf of benhillis November 6, 2025 16:30
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.

fuzz trycopy and fast_memcpy

3 participants