NVIDIA / NVIDIA/cudf

[FEA] Harden Java native-resource cleanup and close safety

Open
#23,939 0 comments 0 reactions 0 assignees View on GitHub
feature request improvement Java
Dominant language
C++
Stars
9.8k
Forks
1.1k
Avg merge
3d 6m
Merged PRs (30d)
278

Description

**Describe the bug**

Several Java wrappers can leak retained resources if native destruction throws. Native operations can also race with `close()`, producing use-after-free, while calls after closure may throw incidental `NullPointerException`s instead of `IllegalStateException`.

**Steps/Code to reproduce bug**

Source-level examples include `HashJoin` and `KeyRemapping` cleanup, concurrent native use and closure, and accessing wrapper metadata after closure. Audit analogous multi-resource cleaners such as `HostColumnVectorCore`.

**Expected behavior**

- Always attempt all cleanup and preserve suppressed exceptions.
- Prevent native handles from being destroyed while in use.
- Explicitly reject use after closure.
- Consolidate common cleaner behavior/naming and simplify `cleanImpl` control flow where appropriate.

**Environment overview (please complete the following information)**

All environments; identified through source review.

**Environment details**

N/A.

**Additional context**

Follow-up to NVIDIA/cudf#22392, particularly the review discussions about [exception-safe cleanup](https://github.com/NVIDIA/cudf/pull/22392#discussion_r3907074093), [close/use races](https://github.com/NVIDIA/cudf/pull/22392#discussion_r3907241235), and [use after close](https://github.com/NVIDIA/cudf/pull/22392#discussion_r3908080644).

Contributor guide

Open the contributing guide

Research direction

Start with the HashJoin and KeyRemapping cleanup examples, then audit the analogous multi-resource cleaner HostColumnVectorCore. Read the linked review discussions on exception-safe cleanup, close/use races, and use after close before deciding the scope. Done means cleanup attempts all resources with suppressed exceptions, native use is safe against close, and post-close access explicitly raises IllegalStateException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.