[rocprofiler-sdk] Add validation and error handling for the extra counter YAML file - #5551
[rocprofiler-sdk] Add validation and error handling for the extra counter YAML file#5551mcao59 wants to merge 7 commits into
Conversation
4650088 to
da3bfbb
Compare
| DEPENDS vector-ops COPY invalid_${invalid_yaml}.yaml | ||
| TIMEOUT 10 | ||
| LABELS "integration-tests" | ||
| WILL_FAIL TRUE) |
There was a problem hiding this comment.
TODO: improvement for tests:
the new integration tests currently verify invalid extra-counter YAML exits with failure (WILL_FAIL TRUE), but they do not assert the emitted error text.
Perhaps I should validate both non-zero exit behavior and user-facing error messages?
10c0613 to
4a478b9
Compare
|
This pull request has been inactive for 25 days and will be marked as stale. If you would like to keep this PR open, please:
This PR will be automatically closed in 5 days if no further activity occurs. |
4a478b9 to
bcc529f
Compare
|
This pull request has been inactive for 25 days and will be marked as stale. If you would like to keep this PR open, please:
This PR will be automatically closed in 5 days if no further activity occurs. |
|
This pull request has been automatically closed due to inactivity (30 days with no updates). If you'd like to continue working on this, feel free to reopen the PR or create a new one. |
65be9ed to
449e879
Compare
✅ All Policy Checks Passed
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🚫 Please fix the failed policies before requesting reviews. The following policy checks failed:
The |
This reverts commit 982753d.
449e879 to
75d4c32
Compare
|
This pull request has been inactive for 25 days and will be marked as stale. If you would like to keep this PR open, please:
This PR will be automatically closed in 5 days if no further activity occurs. |
|
This pull request has been automatically closed due to inactivity (30 days with no updates). If you'd like to continue working on this, feel free to reopen the PR or create a new one. |



Status: blocked by
ROCP_FATALhang issue #6717Rework of #4760
Motivation
Fix SIGSEGV crash in rocprofv3 when invalid counter YAML files are provided via the -E flag.
With invalid counter definitions, the program should exit with meaningful error messages.
With duplicate counter definitions, print warning message and program continues.
Technical Details
1. Add YAML validation for extra counter files
Created dedicated function
validateExtraCounterYAML()which validates YAML and returns optional error msg2. Replace
ROCP_FATALwithROCP_ERROR + std::exit(EXIT_FAILURE)in counter-related code pathsROCP_FATAL:ROCP_FATALand the rocprofiler's signal handler together causes hang:ROCP_ERROR + std::exit(EXIT_FAILURE)3. Add 11 unit test for metrics
Location:
source/lib/rocprofiler-sdk/counters/tests/metrics_test.cppRun:
ctest -R "unit.metrics.validate"Tests the
validateExtraCounterYAML()function with various invalid and valid YAML inputs:validate_malformed_yaml- YAML syntax errors (unclosed quotes, invalid structure)validate_missing_top_key- Missingrocprofiler-sdk:top-level keyvalidate_missing_counters- Missingcounters:array under rocprofiler-sdkvalidate_missing_name- Counter definition withoutname:fieldvalidate_empty_architectures- Emptyarchitectures: []arrayvalidate_no_event_or_expr- Missing bothevent+blockANDexpressionvalidate_event_needs_block- Hasevent:but missing requiredblock:validate_block_needs_event- Hasblock:but missing requiredevent:validate_valid_yaml- Properly formed YAML passes validationvalidate_duplicate_counter_same_arch- Duplicate counter (same name + architecture) warns but doesn't errorvalidate_duplicate_counter_different_arch- Same counter name with different architectures is valid4. Add 8 extra counters integration test
Location:
tests/rocprofv3/counter-collection/extra_counters/Run:
ctest -R "rocprofv3-test-extra-counters-invalid"Tests rocprofv3 with invalid YAML files to verify clean error handling:
invalid_malformed.yaml- Malformed YAML syntaxinvalid_missing_root.yaml- Missingrocprofiler-sdktop-level keyinvalid_missing_counters.yaml- Missingcountersarrayinvalid_missing_name.yaml- Counter without name fieldinvalid_empty_arch.yaml- Empty architectures listinvalid_no_event_expr.yaml- Missing both event/block and expressioninvalid_event_no_block.yaml- Event specified without blockinvalid_block_no_event.yaml- Block specified without eventAll tests use
WILL_FAIL TRUEto verify rocprofv3 exits with error status (not crash).Result: ✅ All 8 tests pass - rocprofv3 exits cleanly with exit code 1
JIRA ID
AIPROFSDK-22
Test Plan
All YAML validation tests pass without crashes. Invalid counter definitions now produce appropriate error messages and gracefully exit the program (or skips the duplicate counters).
Test Result
Submission Checklist