Skip to content

[BUG]: test_program_cache_tmp_dir_created_owner_only fails under a setgid parent directory #3214

Open

Description

@0z5a

Is this a duplicate?

  • I confirmed there appear to be no duplicate issues for this bug and that I agree to the Code of Conduct

Type of Bug

Something else (test-only failure)

Component

cuda.core

Describe the bug

With TMPDIR in a group-shared directory that has the setgid bit (mode 2770), cuda_core/tests/test_program_cache.py::test_program_cache_tmp_dir_created_owner_only fails:

AssertionError: tmp has mode 0o2700

FileStreamProgramCache creates tmp with mkdir(mode=0o700), and on Linux a new directory inherits S_ISGID from a setgid parent. The test compares stat.S_IMODE(...), which keeps the setgid bit, against 0o700. The directory is still owner-only: setgid on a directory only sets the group of new entries and grants no access. Under a parent without setgid, the same test passes.

How to Reproduce

mkdir -p /tmp/sg && chmod 2770 /tmp/sg
TMPDIR=/tmp/sg pytest cuda_core/tests/test_program_cache.py -k tmp_dir_created_owner_only

(The group-shared parent must be one where you may set the setgid bit; any directory with mode 2770 reproduces it.)

Expected behavior

The test checks that tmp is owner-only, which it is; the inherited setgid bit does not grant access and should not fail it.

Proposed fix

Compare only the access bits, stat.S_IMODE(os.stat(root / "tmp").st_mode) & 0o777. With that change, the test passes under the setgid TMPDIR above. I can open a PR.

The fix was written with Claude Opus 5.5 and reviewed by the contributor.

Environment

GPU: B300 (cc 10.3, x86_64) | driver 610.57.04 | CUDA 13.4.2 (local CTK) | Python 3.12 | cuda-python 2da9c65a

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageNeeds the team's attention

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions