Skip to content

pathfinder: make LocatedHeaderDir immutable - #2647

Open
aryanputta wants to merge 1 commit into
NVIDIA:mainfrom
aryanputta:pathfinder/frozen-located-header-dir
Open

pathfinder: make LocatedHeaderDir immutable#2647
aryanputta wants to merge 1 commit into
NVIDIA:mainfrom
aryanputta:pathfinder/frozen-located-header-dir

Conversation

@aryanputta

Copy link
Copy Markdown
Contributor

Description

closes #2646

locate_nvidia_header_directory() is @functools.cache-backed, so every caller gets the same LocatedHeaderDir instance. The dataclass was not frozen, so a write to abs_path on a returned object changed what every later lookup of that libname returned for the rest of the process, including through find_nvidia_header_directory().

This makes LocatedHeaderDir @dataclass(frozen=True), matching LocatedStaticLib and LocatedBitcodeLib, the other two public Located* return types. The __post_init__ path normalization moves to object.__setattr__, which is the standard frozen-dataclass form and keeps the normalization behavior identical. Freezing also makes the type hashable, which its two siblings already were.

This is an intentional behavior change on a public type: code that previously mutated a returned LocatedHeaderDir now raises dataclasses.FrozenInstanceError instead of silently corrupting the shared cache entry. Nothing in cuda_pathfinder or its test suite mutates one, and the two sibling types have always rejected it.

Two tests are added: one drives the real cached lookup, asserts the write is rejected, and asserts a second lookup still returns the discovered directory; one pins hashability and value equality.

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

locate_nvidia_header_directory() is functools.cache-backed and returns a
mutable dataclass, so a caller that writes to the returned object changes
what every later lookup of that libname returns for the life of the
process. Freeze it, matching LocatedStaticLib and LocatedBitcodeLib, which
are the other two public Located* return types.

Signed-off-by: Aryan Putta <aryansputta@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added the cuda.pathfinder Everything related to the cuda.pathfinder module label Aug 16, 2026
@mdboom

mdboom commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

/ok to test 946d8b0

@mdboom mdboom self-assigned this Aug 20, 2026
@mdboom mdboom added this to the cuda.pathfinder next milestone Aug 20, 2026
@github-actions

Copy link
Copy Markdown

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

Labels

cuda.pathfinder Everything related to the cuda.pathfinder module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: LocatedHeaderDir is mutable, so callers can poison the cached header-directory lookup

2 participants