Conversation
Agent-Logs-Url: https://github.com/darnstrom/daqp/sessions/620a58a4-98fa-45cd-834f-666200a6c85e Co-authored-by: darnstrom <55484604+darnstrom@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix erratic behaviour in minrep function due to uninitialized variables
Fix uninitialized work->x in daqp_check_unconstrained when no linear term
Mar 27, 2026
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.
daqp_check_unconstraineduseswork->xold(malloc'd, uninitialized) as scratch space by swapping it intowork->x, then skips writing to it whenwork->v == NULL(nofterm). The subsequent feasibility check reads garbage, causing the unconstrained shortcut to fire incorrectly—or not at all—for pure quadratic problems (min 0.5 x'Hx, no linear term).When the shortcut fires incorrectly,
sing_indis set toDAQP_UNCONSTRAINED_OPTIMALand the extracted primal solution is garbage from uninitialized memory. This is the root cause of the erraticminrepbehaviour reported after the unconstrained-feasibility shortcut was introduced.Changes
src/utils.c— Indaqp_check_unconstrained, add anelsebranch coveringwork->v == NULL. The unconstrained optimum ofmin 0.5 x'Hxis alwaysx = 0, so zero the scratch buffer before the feasibility check:interfaces/daqp-eigen/tests/08_unconstrained_check.cpp— Two new test cases:min 0.5||x||²s.t.-1 ≤ x ≤ 1:x = 0is feasible → shortcut must returnx* = 0min 0.5||x||²s.t.2 ≤ x ≤ 5:x = 0violates bounds → shortcut must not fire; solver returnsx* = [2, 2]📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.