WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

[BUG]: __cccl_allocation_stream invokes cuda-driver UB #6862

@wence-

Description

@wence-

Is this a duplicate?

Type of Bug

Something else

Component

libcu++

Describe the bug

I noticed that cuda::__cccl_allocation_stream holds a static-lifetime cuda::stream

inline ::cuda::stream_ref __cccl_allocation_stream()
{
  static ::cuda::stream __stream{device_ref{0}};
  return __stream;
}

The dtor (and hence cuStreamDestroy) will run below main. But, quoth the documentation

The CUDA interfaces use global state that is initialized during host program initiation and destroyed during host program termination. The CUDA runtime and driver cannot detect if this state is invalid, so using any of these interfaces (implicitly or explicitly) during program initiation or termination after main) will result in undefined behavior.

oops.

How to Reproduce

n/a

Expected behavior

No UB.

Reproduction link

No response

Operating System

No response

nvidia-smi output

No response

NVCC version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working right.

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions