[BUG] Out-of-bounds read when solving a DataModel with lower/upper constraint bounds
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start with _compute_slack_csr, the function the report names as reading the rhs and sense arrays, and compare it with how a DataModel built through set_constraint_lower_bounds() and set_constraint_upper_bounds() fills those arrays. Run the reproducer in the issue, which should print slack near zero for x >= 1. Done means the slack is computed from the constraint bounds without reading the empty arrays, and the Cython bounds-checked run no longer reports an out-of-bounds access.
索引モデルが issue の本文から書いたものです。
説明
(AI-assisted bug report)
cuopt.linear_programming.Solve accepts a DataModel whose constraints are supplied through set_constraint_lower_bounds() and set_constraint_upper_bounds(). When it constructs a Solution with a primal vector, its Python/Cython slack calculation instead reads the alternative RHS and row-sense arrays. Those arrays are empty for this valid DataModel representation. Because Cython bounds checking is disabled, the code reads outside both arrays. The read can produce an incorrect slack or terminate the process with SIGSEGV.
Reproducer:
import numpy as np
from cuopt.linear_programming.data_model import DataModel
from cuopt.linear_programming.solver import Solve
from cuopt.linear_programming.solver_settings import SolverMethod, SolverSettings
# Minimize x subject to x >= 1.
dm = DataModel()
dm.set_csr_constraint_matrix(
np.array([1.0]),
np.array([0], dtype=np.int32),
np.array([0, 1], dtype=np.int32),
)
dm.set_objective_coefficients(np.array([1.0]))
dm.set_variable_lower_bounds(np.array([0.0]))
dm.set_variable_upper_bounds(np.array([np.inf]))
dm.set_variable_types(np.array(["C"], dtype="S1"))
dm.set_constraint_lower_bounds(np.array([1.0]))
dm.set_constraint_upper_bounds(np.array([np.inf]))
print(
"rows=1",
"rhs=", len(dm.get_constraint_bounds()),
"sense=", len(dm.get_row_types()),
"lower=", len(dm.get_constraint_lower_bounds()),
"upper=", len(dm.get_constraint_upper_bounds()),
flush=True,
)
settings = SolverSettings()
settings.set_parameter("method", SolverMethod.PDLP)
settings.set_parameter("log_to_console", False)
solution = Solve(dm, settings)
print(solution.get_termination_reason())
print("x=", solution.get_primal_solution())
print("slack=", solution.get_slack())
Observed locally:
rows=1 rhs= 0 sense= 0 lower= 1 upper= 1
Optimal
x= [1.]
slack= [-1.]
The constraint is x >= 1 so we'd expect the slack to be zero. I observed segfaults on other instances.
The source of the issue is _compute_slack_csr which reads from the rhs and sense vectors which aren't initialized in this DataModel code path. Running with bounds checking enabled in Cython confirms the out of bounds access.
- 主要言語
- Cuda
- スター
- 1.1k
- フォーク
- 249
- 平均マージ
- 1日 16時間
- マージ済み PR(30日)
- 127
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
NVIDIA/cuopt のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
feature request
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
NVIDIA/cuopt#2239 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
メンテナーはふだん 1 日以内に返信
-
[BUG] Java: Problem.addConstraint accepts the same Constraint twice対応中かも @akhil9tiet が 5 日前に担当しました。 オープンbug
NVIDIA/cuopt#2224 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 63/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
lidge-jun/opencodex#8101 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
effort:S P3 refactor
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
nightscout/nocturne#3243 ·
メンテナーはふだん 1 日以内に返信
-
date_time, url_encode, html_escape, to_unix_time, contains_all and contains_any panic when called without arguments対応中かも @antcybersec が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
projectdiscovery/dsl#372 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
yegor256/intercepted#128 ·
-
Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
keiyoushi/extensions-source#20650 ·
メンテナーはふだん 1 日以内に返信