Skip to content

Fix NULL scaling dereference in daqp_apply_Rinv for generated code - #221

Merged
darnstrom merged 1 commit into
masterfrom
fix-codegen-rinv-scaling
Oct 14, 2026
Merged

darnstrom merged 1 commit into
masterfrom
fix-codegen-rinv-scaling

Conversation

@darnstrom

Copy link
Copy Markdown
Owner

Fixes the segfault in the downstream LinearMPC.jl CI job (https://github.com/darnstrom/daqp/actions/runs/38648880314/job/116142467566), introduced in #220.

Cause

#220 changed the unscaling guard in daqp_apply_Rinv from work->scaling != NULL to work->state & DAQP_STATE_RINV_NORMALIZED. Generated workspaces (codegen/codegen.c) keep the normalized flag in state but always set scaling = NULL, since they store the normalized LDP without the scaling array. When there are simple bounds, generated code then dereferences NULL in ldp2qp_solution → daqp_apply_Rinv.

Fix

Require both the flag and scaling != NULL. For generated code this restores the behavior from before #220.

Testing

  • Ran the LinearMPC.jl test suite locally against this branch: 467/467 pass. Without the fix, it segfaults the same way CI does.
  • Note: DAQPBase.codegen downloads the C sources from master on GitHub, so the downstream CI job won't pick up this fix until it is merged. For the local run I temporarily pointed it at the branch's sources.

🤖 Generated with Claude Code

#220 switched the unscaling in daqp_apply_Rinv from a scaling != NULL
check to the DAQP_STATE_RINV_NORMALIZED flag. Generated workspaces keep
the flag but store scaling = NULL, so generated code (e.g. LinearMPC.jl
codegen tests) dereferenced NULL in ldp2qp_solution. Require both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@darnstrom
darnstrom merged commit b05399a into master Oct 14, 2026
18 of 19 checks passed
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.

1 participant