Skip to content

[BUG] Memory leak in comms #435

Closed
@seunghwak

Description

Describe the bug
comms_iface has no virtual destructor
(https://github.com/rapidsai/raft/blob/branch-22.02/cpp/include/raft/comms/comms.hpp#L91).
This means std_comms or mpi_comms destructor will not be called when comms_t's destructor is called and std::unique_ptr<comms_iface> impl_; gets destructed (https://github.com/rapidsai/raft/blob/branch-22.02/cpp/include/raft/comms/comms.hpp#L608).

Also,

initialize_mpi_comms with the given MPI_Comm comm calls mpi_comms with owns_mpi_comm = true
(https://github.com/rapidsai/raft/blob/branch-22.02/cpp/include/raft/comms/mpi_comms.hpp#L442).
cuGraph calls initialize_mpi_comms(&handle, MPI_COMM_WORLD) and as owns_mpi_comms is set to true, mpi_comms destructor will call MPI_Comm_free. This is erroneous.

Additional context
virtual ~comms_iface() {} should be added to class comms_iface.
initialize_mpi_comms should call mpi_comms with owns_mpi_comms = false (and caller should be responsible for destroying comm).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions