Skip to content

Fix uninitialized memory in allocate_daqp_workspace and Eigen interface#148

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/analyze-memory-leaks-daqp
Draft

Fix uninitialized memory in allocate_daqp_workspace and Eigen interface#148
Copilot wants to merge 2 commits intomasterfrom
copilot/analyze-memory-leaks-daqp

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 27, 2026

Valgrind identified 111 uninitialized-memory errors across the Eigen C++ tests (03, 04, 05) and zero memory leaks. Three bugs fixed:

  • work->m / work->ms never initialized (src/api.c): allocate_daqp_workspace set work->n but left work->m and work->ms as garbage. The DAQP class calls this function in its constructor, and resize_result then compares m != work_.m before daqp_update_ldp has had a chance to populate those fields.

    // Before
    work->n = n;
    n = n + ns;
    
    // After
    work->n = n;
    work->m = 0;
    work->ms = 0;
    n = n + ns;
  • slack_ allocated but not zeroed (daqp.cpp): EigenDAQPResult::resize_dual used slack_.resize(m), which allocates without initializing. Callers copying the result and calling get_slack() before set_slack() received garbage values. Changed to slack_.setZero(m).

  • DAQP::solve(A, bu, bl, break_points) returned result with unpopulated slack (daqp.cpp): Unlike the standalone daqp_solve(), the class method never called set_slack before returning. Added a get_slack() call so that a copied EigenDAQPResult carries valid slack data, matching the static function's behavior.


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Copilot AI changed the title [WIP] Analyze latest version of daqp for memory leaks and uninitialized memory Fix uninitialized memory in allocate_daqp_workspace and Eigen interface Mar 27, 2026
Copilot AI requested a review from darnstrom March 27, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants