NVIDIA / NVIDIA/stdexec

nvexec `let_value` et al assumes sender returned from lambda is a stream sender

Open
#1,059 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug cuda P1
Dominant language
C++
Stars
2.4k
Forks
270
Avg merge
3d 6h
Merged PRs (30d)
39

Description

nvexec's customization of let_value calls the lambda and constructs the result sender in temporary storage (good), but it unconditionally attaches a propagate_receiver_t. If that sender is not a stream sender, and if it completes with reference(s) to objects in host memory (say, if it passes to propagate_receiver_t's set_value references to temporaries that live on the host caller's stack, then when device code accesses the values, the process will crash because host memory is inaccessible.

E.g., this crashes:

nvexec::stream_context ctx;

auto snd = stdexec::schedule( ctx.get_scheduler() )
         | stdexec::let_value( [] {
             // this sender will complete with an rvalue reference to
             // an integer in host memory:
             return stdexec::just() | stdexec::then( [] { return 42; } );
           })
           // This sender's receiver, wrapped in `propagate_receiver_t`,
           // will accept the reference to host memory and pass it into
           // a kernel that calls this lambda, causing an access violation.
         | stdexec::then( [] (int i) { ... } );

stdexec::sync_wait( std::move(snd) );

The stream scheduler's let_value customization must assume, if the result sender is not a stream sender, that any values/errors it may complete with are kept in host memory and defensively copy them into device memory.

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 with nvexec's stream scheduler let_value customization and the provided reproducer, then inspect how propagate_receiver_t handles results from non-stream senders. Done means values and errors from non-stream result senders are defensively copied into device memory before device access, and the example no longer crashes.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
hpc
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.