DataModel: validate constraint array lengths against the row count
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- Nửa ngày
- Mức phù hợp với người mới
- 50/100
Hướng nghiên cứu
Start in the setters in data_model_wrapper.pyx that store rhs, row types and the constraint lower/upper bounds, and compare their lengths with len(A_offsets) - 1. First check whether the C++ data_model_view already validates these sizes, since that decides where the check belongs. Done means a clear ValueError for mismatched lengths or half-set bounds, plus a test that covers the bounds-only path used by cvxpy, pyomo and linopy.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
DataModel accepts two row representations: rhs + row types (set_constraint_bounds, set_row_types) and lower/upper bounds (set_constraint_lower_bounds, set_constraint_upper_bounds). The setters in data_model_wrapper.pyx store whatever array they receive. Nothing checks that its length equals the row count implied by A_offsets (len(A_offsets) - 1).
The solve path then passes each array to the C++ data_model_view with its own shape[0]. Any consumer that assumes one representation, or assumes the sizes match, can read out of bounds. #2249 is one instance, in _compute_slack_csr, which indexed rhs[i] and sense[i] when only the bounds were set. cvxpy, pyomo and linopy all use set_constraint_lower_bounds, so this path is exercised by third-party interfaces.
Proposal
Validate at the Python boundary (the setters, or the solve entry once the matrix is known):
rhs,row_types,constraint_lower_boundsandconstraint_upper_boundsmust each be empty or have length equal to the row count.- Lower and upper bounds must be set together or not at all.
- Raise a clear
ValueErrorotherwise.
Optionally, as Ishika Roy suggested, normalize so that rhs + sense is always converted to lower/upper bounds when the model is built, so consumers only deal with one representation. That is a larger change and could be a second step.
Open question
Does the C++ data_model_view already validate these sizes against the row count? That needs checking, since the Python-side check would then be a duplicate of it.
Related: #2249, #2253, #1615.
- Ngôn ngữ chính
- Cuda
- Star
- 1.1k
- Fork
- 249
- Merge trung bình
- 1 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 124
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của NVIDIA/cuopt
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 32/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
NVIDIA/cuopt#2255 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] Out-of-bounds read when solving a DataModel with lower/upper constraint boundsCó thể đã có người làm @ramakrishnap-nv đã nhận hôm nay. Đang mởbug
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 55/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
hyperledger/fabric-x-orderer#1409 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
fixed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
firefly-iii/firefly-iii#13150 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày