Skip to content

Fix double va_start undefined behavior in error handling#1086

Open
rgsl888prabhu wants to merge 2 commits intoNVIDIA:mainfrom
rgsl888prabhu:fix/double-va-start-undefined-behavior
Open

Fix double va_start undefined behavior in error handling#1086
rgsl888prabhu wants to merge 2 commits intoNVIDIA:mainfrom
rgsl888prabhu:fix/double-va-start-undefined-behavior

Conversation

@rgsl888prabhu
Copy link
Copy Markdown
Collaborator

@rgsl888prabhu rgsl888prabhu commented Apr 9, 2026

Summary

Remove duplicate va_start() calls in cuopt_expects(), mps_parser_expects(), and mps_parser_expects_fatal(). Calling va_start() twice on the same va_list without an intervening va_end() is undefined behavior per the C standard.

Testing

No new tests added. Existing unit tests cover these error handling paths.

Documentation

No documentation changes needed.

Remove duplicate va_start() calls in cuopt_expects(), mps_parser_expects(),
and mps_parser_expects_fatal(). Calling va_start() twice on the same va_list
without an intervening va_end() is undefined behavior per the C standard and
can corrupt the stack or produce garbage error messages.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rgsl888prabhu rgsl888prabhu requested a review from a team as a code owner April 9, 2026 15:57
@rgsl888prabhu rgsl888prabhu self-assigned this Apr 9, 2026
@rgsl888prabhu rgsl888prabhu added bug Something isn't working non-breaking Introduces a non-breaking change labels Apr 9, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 9, 2026

📝 Walkthrough

Walkthrough

Two error handling header files are updated to remove redundant va_start() calls in macro definitions where variable argument lists were initialized multiple times. One file also updates the copyright year range.

Changes

Cohort / File(s) Summary
Cuopt Error Handling
cpp/include/cuopt/error.hpp
Removed redundant va_start(args, fmt); call in cuopt_expects macro, consolidating variable argument initialization to a single point before vsnprintf.
MPS Parser Error Handling
cpp/libmps_parser/src/utilities/error.hpp
Removed redundant va_start(args, fmt); calls in mps_parser_expects and mps_parser_expects_fatal macros; updated SPDX copyright year range from 2023-2025 to 2023-2026.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change—removing duplicate va_start() calls to fix undefined behavior in error handling macros.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description check ✅ Passed The PR description clearly explains the changes, identifies the specific undefined behavior being fixed (duplicate va_start calls), cites the relevant C standard, and describes the testing approach.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Labels

bug Something isn't working non-breaking Introduces a non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant