cuvs icon indicating copy to clipboard operation
cuvs copied to clipboard

[C] Fix: `cuvsRMMMemoryResourceReset` sets a valid resource

Open ldematte opened this issue 1 month ago • 3 comments

In cuvsRMMMemoryResourceReset, we currently call rmm::mr::set_current_device_resource(nullptr); but this generates segfaults (more specifically, a tentative to dereference a NULL pointer)

We should either save the original resource we get inside cuvsRMMPoolMemoryResourceEnable (returning some state, e.g. via a new cuvsRMMMemoryResource_t -- which may be get rid of the thread local too, if we find it convenient), and pass it back to cuvsRMMMemoryResourceReset so it can restore it.

Or reset the resource to some initial, valid instance. The new rmm::mr::reset_current_device_resource_ref() (see https://github.com/rapidsai/rmm/blob/f965b7f98805e96ccd4fb3e7774f9b8e38ad2bdb/cpp/include/rmm/mr/per_device_resource.hpp#L466) does that.

This PR follows the second approach and replicates reset_current_device_resource_ref behaviour in cuvsRMMMemoryResourceReset, by resetting the current device resource to rmm::mr::detail::initial_resource().

Fixes https://github.com/rapidsai/cuvs/issues/1454

ldematte avatar Nov 14 '25 13:11 ldematte

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

copy-pr-bot[bot] avatar Nov 14 '25 13:11 copy-pr-bot[bot]

Ah, I'm not on @rapidsai/cuvs-cpp-codeowners. @benfred: This might need a quick gander.

mythrocks avatar Nov 17 '25 18:11 mythrocks

/ok to test 0f6df12

mythrocks avatar Nov 17 '25 18:11 mythrocks

@robertmaynard @benfred Rebased on release/25.12, now the changeset is clean

ldematte avatar Nov 18 '25 08:11 ldematte

Hi, @ldematte.

I'll mention this here before @cjnolet does: For RAPIDS projects, the recommendation is not to do force pushes, to prevent review comments from disappearing, etc.

mythrocks avatar Nov 18 '25 17:11 mythrocks

@mythrocks I usually don't do that, but in case of a rebase to another branch (main -> 25.12 in this case) this is necessary (I think? If you know a better way, please correct me!)

ldematte avatar Nov 18 '25 17:11 ldematte

/ok to test c486f11

mythrocks avatar Nov 18 '25 18:11 mythrocks

in case of a rebase to another branch...

Fair point. And in this case, the prior review comments remained intact, so there's no adverse consequence.

mythrocks avatar Nov 18 '25 18:11 mythrocks

Argh. It looks like we need to run pre-commit to fix the formatting in the C test file.

mythrocks avatar Nov 18 '25 20:11 mythrocks

That's very strange, I have installed the pre-commit hook. Maybe it got updated? Anyway, will run it

ldematte avatar Nov 19 '25 09:11 ldematte

/ok to test e0a78ed

mythrocks avatar Nov 19 '25 17:11 mythrocks

/merge

benfred avatar Nov 20 '25 05:11 benfred