Skip to content

[Question] Is there undefined behavior between the calls to cudaFree and cudaIpcCloseMemHandle? #497

@hexclover

Description

@hexclover

In Buffer::destroy, each rank first closes the 7 external memory handles, then cudaFrees the local buffer.

However, the docs for cudaIpcOpenMemHandle says it is undefined behavior to cudaFree the exported memory region before the call to cudaIpcCloseMemHandle.

So in an extreme situation (actually I think this may be common) it is possible for rank 2 to close the handle exported from rank 1 long after rank 1 has freed that buffer. This should be technically considered undefined behavior, although I haven't been able to construct a test that exhibits clearly erroneous behavior, e. g. crashes.

Basically I am wondering about the robustness of this code: is it UB? Does it just happen to work? Or it is guaranteed to work given the current CUDA implementations?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions