llnl / llnl/camp

host resource memcpy undefined behavior

Open
#156 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
107
Forks
26
Avg merge
8d 11h
Merged PRs (30d)
2

Description

In playing with undefined behavior sanitizer I learned that it is undefined behavior to pass a nullptr to std::memcpy even if the count/size argument is 0, see https://en.cppreference.com/w/cpp/string/byte/memcpy.
Do we want to allow users to pass nullptr to camp::resources::Host::memcpy with a count/size of 0?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at camp::resources::Host::memcpy and inspect how zero-length calls reach std::memcpy. Determine the intended contract for nullptr with a zero count, then add focused coverage for that behavior. Done means the API decision is documented in tests and sanitizer checks no longer report the case.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend-api-design
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.