Harden OPG Data byte-size computation against overflow - #8319
Harden OPG Data byte-size computation against overflow#8319fallintoplace wants to merge 4 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR adds overflow-checked byte-size calculations to ChangesChecked-arithmetic sizing update
Estimated code review effort: 2 (Simple) | ~15 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: e9ca7533-1d52-4d76-84a1-eac1cca07ef5
📒 Files selected for processing (8)
cpp/bench/common/ml_benchmark.hppcpp/include/cuml/prims/opg/matrix/data.hppcpp/src/glm/ridge_mg.cucpp/src/solver/cd_mg.cucpp/src_prims/opg/linalg/lstsq.cucpp/tests/CMakeLists.txtcpp/tests/prims/matrix_data.cppcpp/tests/prims/ml_benchmark.cpp
|
/ok to test 32e43a3 |
32e43a3 to
4a0991b
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cpp/tests/prims/matrix_data.cpp`:
- Line 36: Declare the zero-length Data<float> instance before EXPECT_THROW,
then invoke setNumElements on that named object inside the macro so the braced
initializer comma does not split the macro arguments.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 7964be35-570b-46c7-b81b-5b261f659209
📒 Files selected for processing (8)
cpp/bench/common/ml_benchmark.hppcpp/include/cuml/prims/opg/matrix/data.hppcpp/src/glm/ridge_mg.cucpp/src/solver/cd_mg.cucpp/src_prims/opg/linalg/lstsq.cucpp/tests/CMakeLists.txtcpp/tests/prims/matrix_data.cppcpp/tests/prims/ml_benchmark.cpp
🚧 Files skipped from review as they are similar to previous changes (6)
- cpp/src/solver/cd_mg.cu
- cpp/src/glm/ridge_mg.cu
- cpp/bench/common/ml_benchmark.hpp
- cpp/tests/CMakeLists.txt
- cpp/src_prims/opg/linalg/lstsq.cu
- cpp/include/cuml/prims/opg/matrix/data.hpp
What changed
cpp/include/cuml/prims/opg/matrix/data.hpp.MLCommon::Matrix::Datato explicitly store element count innElements, and keepnumElements()returning that value.setNumElements()helper and migrate internal assignments to avoid writingtotalSizedirectly with element counts.cpp/tests/prims/matrix_data.cppand register viacpp/tests/CMakeLists.txt.Why
Datapreviously multiplied bysizeof(Type)without overflow checks, allowing silent wraparound on large block sizes. This also made byte-size vs element-count handling easy to get wrong; storing both avoids the confusion and makes unit size bookkeeping explicit.Notes
I did not run tests in this pass.