fix lifetime bug with presolve result#907
Conversation
📝 WalkthroughWalkthroughMoved a presolver result variable in the PDLP solver from inner to outer scope to persist its value across control flow, and added defaulted move constructor and move assignment to the optimization_problem_t class to enable move semantics; no other behavioral changes introduced. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
65afe84 to
d21b147
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cpp/src/pdlp/solve.cu (1)
1206-1206: Add an explicit<optional>include to cpp/src/pdlp/solve.cu.
std::optionalis used directly at line 1206; relying on transitive includes from third_party_presolve.hpp is brittle and can break with unrelated header changes.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cpp/src/pdlp/solve.cu` at line 1206, Add an explicit include for the <optional> header in the file that defines the use of std::optional (so that std::optional is available for the declaration of std::optional<detail::third_party_presolve_result_t<i_t, f_t>> result;). Locate the top-of-file includes in solve.cu and insert `#include` <optional> (before or alongside other standard headers) so the code no longer relies on transitive includes from third_party_presolve.hpp.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@cpp/src/pdlp/solve.cu`:
- Line 1206: Add an explicit include for the <optional> header in the file that
defines the use of std::optional (so that std::optional is available for the
declaration of std::optional<detail::third_party_presolve_result_t<i_t, f_t>>
result;). Locate the top-of-file includes in solve.cu and insert `#include`
<optional> (before or alongside other standard headers) so the code no longer
relies on transitive includes from third_party_presolve.hpp.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
cpp/include/cuopt/linear_programming/optimization_problem.hppcpp/src/pdlp/solve.cu
|
actually it looks like this exact fix is need on #908 perhaps the memory model changes set up the right conditions |
|
this change was included in #908 |
During local development and testing I had reproducible crashes during presolve tests. This appears to be because the presolve result was declared in an inner scope, but the reduced problem is referenced by problem.original_problem_ptr in an outer block at line 1279.
I have not seen this in CI, but timing and memory layout on my local machine may have exposed a latent issue. This change resolved the crash for me.
Summary by CodeRabbit