test: keep OOM tests compatible with newer compilers#138
Closed
yangzhg wants to merge 1 commit into
Closed
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #138 +/- ##
=======================================
Coverage 69.67% 69.67%
=======================================
Files 27 27
Lines 3706 3706
Branches 1189 1189
=======================================
Hits 2582 2582
Misses 211 211
Partials 913 913 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates a few OOM-focused unit tests and a DOM teardown path to avoid GCC 12/13 warning diagnostics (treated as errors) that prevent the tests from building, while preserving the intent of exercising runtime OOM behavior.
Changes:
- Add headroom before padded buffers used by
ParseLazyOOM tests and pass the shifted data pointer to avoid GCC-Warray-boundsdiagnostics. - Make the “huge allocation” size in stack OOM tests a runtime value to avoid GCC
-Walloc-size-larger-thanat compile time. - Mark
DNode::MetaNode’s destructor asnoinlineto avoid GCC object-size analysis folding through DOM teardown.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/parser_oom_test.cpp | Adds headroom + helper accessor so lazy-parse OOM tests use a shifted buffer pointer and avoid GCC bounds warnings. |
| tests/allocator_test.cpp | Makes the huge allocation size runtime-derived to keep OOM stack tests buildable under GCC warning-as-error. |
| include/sonic/dom/dynamicnode.h | Applies noinline to MetaNode destructor to prevent GCC mis-analysis during teardown. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
-Walloc-size-larger-thanbefore the test can exercise runtime OOM behavior.-Warray-boundsdiagnostics.DNode::MetaNodedestruction as noinline to avoid GCC 12 incorrectly folding the object-size analysis through DOM teardown.Why
This is a small compatibility prerequisite before the OOM split PRs. The current
masterfails locally under GCC 12/13 when compiling:unittestwith warning-as-error, even before theoom-corechanges can be validated.Validation
bazel test :unittest --//:sonic_arch=haswell --//:sonic_dispatch=static --//:sonic_sanitizer=no --test_filter='*Allocator*:*WriteBuffer*'with GCC 13CC=gcc-12 CXX=g++-12 bazel test :unittest --//:sonic_arch=haswell --//:sonic_dispatch=static --//:sonic_sanitizer=no --test_filter='*Allocator*:*WriteBuffer*'CC=clang CXX=clang++ bazel test :unittest --//:sonic_arch=haswell --//:sonic_dispatch=static --//:sonic_sanitizer=no --test_filter='*Allocator*:*WriteBuffer*'git diff --cached --check