Skip to content

cuda: For the disabled reason in cuda_init_private check the snprintf return value with PAPI_HUGE_STR_LEN instead of PAPI_MAX_STR_LEN#490

Merged
Treece-Burgess merged 1 commit intoicl-utk-edu:masterfrom
Treece-Burgess:09-30-25-cuda-fully-write-err-string
Oct 12, 2025
Merged

Conversation

@Treece-Burgess
Copy link
Contributor

@Treece-Burgess Treece-Burgess commented Sep 30, 2025

Pull Request Description

Issue/Background:
Currently in the master branch, writing the disabled reason in cuda_init_private can result in the reason being truncated. This is due to the following block of code:

strLen = snprintf(_cuda_vector.cmp_info.disabled_reason, PAPI_HUGE_STR_LEN, "%s", err_string);
if (strLen < 0 || strLen >= PAPI_MAX_STR_LEN) {
    SUBDBG("Failed to fully write the disabled reason.\n");
}

snprintf can write up to a maximum of PAPI_HUGE_STR_LEN; however, the check just below it uses PAPI_MAX_STR_LEN.

Resolution:
This PR resolves this issue by changing PAPI_MAX_STR_LEN to PAPI_HUGE_STR_LEN.

Testing

As we currently do not have any error message strings that are larger than 128 characters. I created a custom error message that exceeded 128 characters. On the master branch, this would result in the SUBDBG message of Failed to fully write the disabled reason.. However, for this PR that did not occur.

Author Checklist

  • Description
    Why this PR exists. Reference all relevant information, including background, issues, test failures, etc
  • Commits
    Commits are self contained and only do one thing
    Commits have a header of the form: module: short description
    Commits have a body (whenever relevant) containing a detailed description of the addressed problem and its solution
  • Tests
    The PR needs to pass all the tests

@Treece-Burgess Treece-Burgess added component-cuda PRs and Issues related to the cuda component status-ready-for-review PR is ready to be reviewed type-bug Issues discussing bugs or PRs fixing bugs labels Sep 30, 2025
@dbarry9
Copy link
Contributor

dbarry9 commented Oct 8, 2025

I am testing this pull request.

Copy link
Contributor

@dbarry9 dbarry9 left a comment

Choose a reason for hiding this comment

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

I tested these changes on an NVIDIA GeForce RTX 5080 device (Blackwell architecture) with CUDA 12.9. The component tests pass or are skipped (consistent with the master branch), and the PAPI utilities function properly.

… return value with PAPI_HUGE_STR_LEN instead of PAPI_MAX_STR_LEN
@Treece-Burgess Treece-Burgess force-pushed the 09-30-25-cuda-fully-write-err-string branch from b07ec67 to 70f6255 Compare October 12, 2025 22:45
@Treece-Burgess Treece-Burgess merged commit 9a4f5c5 into icl-utk-edu:master Oct 12, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component-cuda PRs and Issues related to the cuda component status-ready-for-review PR is ready to be reviewed type-bug Issues discussing bugs or PRs fixing bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants