Skip to content

Fix use-after-free in memory_stats_logger - #22333

Merged
rapids-bot[bot] merged 7 commits into
NVIDIA:mainfrom
PointKernel:fix-memory-stats-logger-uaf
Apr 29, 2026
Merged

rapids-bot[bot] merged 7 commits into
NVIDIA:mainfrom
PointKernel:fix-memory-stats-logger-uaf

Conversation

@PointKernel

@PointKernel PointKernel commented Apr 29, 2026 •

Copy link
Copy Markdown
Member

Description

After #22008, cudf::set_current_device_resource() returns the previous resource as an owning any_resource. memory_stats_logger discarded that return value and held a non-owning device_async_resource_ref to the now-destroyed pool, causing a segfault on the next allocation (e.g. GROUPBY_NVBENCH -b 4 crashed on iteration 2).

Follow-up

Mark RMM's set_*/reset_*_device_resource [[nodiscard]] so this misuse fails at compile time.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@PointKernel
PointKernel requested a review from a team as a code owner April 29, 2026 20:27
@PointKernel PointKernel added bug Something isn't working libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change labels Apr 29, 2026
@copy-pr-bot

copy-pr-bot Bot commented Apr 29, 2026

Copy link
Copy Markdown

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.

@PointKernel

Copy link
Copy Markdown
Member Author

/ok to test e5ebc94

@PointKernel PointKernel added the 3 - Ready for Review Ready for review by team label Apr 29, 2026

@bdice bdice left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this fix! I suggested one alternative which I believe is equivalent.

Comment thread cpp/benchmarks/common/memory_stats.hpp Resolved
@PointKernel

Copy link
Copy Markdown
Member Author

pre-commit.ci autofix

@PointKernel

Copy link
Copy Markdown
Member Author

/ok to test 931a355

Comment thread cpp/benchmarks/common/memory_stats.hpp Resolved

@davidwendt davidwendt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this conflicts with this PR #22267 at least for the gtests fixture changes.
I'm not sure how best to resolve this.

@PointKernel

Copy link
Copy Markdown
Member Author

I feel like this conflicts with this PR #22267 at least for the gtests fixture changes. I'm not sure how best to resolve this.

Ah, I didn’t realize #22267 was already in place. Let me revert my test changes so we can focus just on fixing the benchmark here.

@PointKernel
PointKernel requested a review from davidwendt April 29, 2026 21:02
@PointKernel

Copy link
Copy Markdown
Member Author

/ok to test 0564656

@PointKernel

Copy link
Copy Markdown
Member Author

/merge

@rapids-bot
rapids-bot Bot merged commit a70657c into NVIDIA:main Apr 29, 2026
133 checks passed
@PointKernel
PointKernel deleted the fix-memory-stats-logger-uaf branch April 29, 2026 22:03
vyasr pushed a commit to vyasr/cudf that referenced this pull request May 4, 2026
After NVIDIA#22008, `cudf::set_current_device_resource()` returns the previous resource as an owning `any_resource`. `memory_stats_logger` discarded that return value and held a non-owning `device_async_resource_ref` to the now-destroyed pool, causing a segfault on the next allocation (e.g. `GROUPBY_NVBENCH -b 4` crashed on iteration 2).

### Follow-up

Mark RMM's `set_*/reset_*_device_resource` `[[nodiscard]]` so this misuse fails at compile time.

Authors:
  - Yunsong Wang (https://github.com/PointKernel)
  - https://github.com/apps/pre-commit-ci

Approvers:
  - Bradley Dice (https://github.com/bdice)
  - Muhammad Haseeb (https://github.com/mhaseeb123)
  - David Wendt (https://github.com/davidwendt)

URL: NVIDIA#22333
shrshi pushed a commit to shrshi/cudf that referenced this pull request May 12, 2026
After NVIDIA#22008, `cudf::set_current_device_resource()` returns the previous resource as an owning `any_resource`. `memory_stats_logger` discarded that return value and held a non-owning `device_async_resource_ref` to the now-destroyed pool, causing a segfault on the next allocation (e.g. `GROUPBY_NVBENCH -b 4` crashed on iteration 2).

### Follow-up

Mark RMM's `set_*/reset_*_device_resource` `[[nodiscard]]` so this misuse fails at compile time.

Authors:
  - Yunsong Wang (https://github.com/PointKernel)
  - https://github.com/apps/pre-commit-ci

Approvers:
  - Bradley Dice (https://github.com/bdice)
  - Muhammad Haseeb (https://github.com/mhaseeb123)
  - David Wendt (https://github.com/davidwendt)

URL: NVIDIA#22333
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3 - Ready for Review Ready for review by team bug Something isn't working libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants