Skip to content

Fix crashes on unfactored objects and bad permutations, and keep the singular status - #53

Merged
ViralBShah merged 1 commit into
mainfrom
fix-unfactored-and-status
Oct 30, 2026
Merged

ViralBShah merged 1 commit into
mainfrom
fix-unfactored-and-status

Conversation

@ViralBShah

Copy link
Copy Markdown
Member

Fixes bugs found while reviewing test coverage on main. Each one reproduced before the fix:

Input Before Now
KLUFactorization(A).p, .q or .Rs, or the same after klu(A; full_factor = false) Segfault in klu_sort ArgumentError
klu_analyze!(K, P, Q) with 1-based or invalid permutations Segfault in btf_strongcomp ArgumentError
Solving with, reading factors of, or printing klu(S; allowsingular = true) issuccess becomes true Status stays KLU_SINGULAR
klu(n, colptr, rowval, nzval; check = false) with an invalid pattern Throws Returns with KLU_INVALID
klu!(klu(A; full_factor = false), nzval) Throws, and the object stays unusable Computes the first factorization

The lost status is the same bug as rgrowth in #43: libklu resets common.status on entry. It matters because solve!'s docs tell users to check that status.

The existing "Permutation vectors" test passed 1-based vectors but never reached libklu, because klu_analyze! returns early on an analyzed object. It now analyzes a new object with zero-based permutations, and the docstring says they're zero-based.

Testing

The tests are folded into the existing testsets. The full suite passes locally on Linux with Julia 1.13 and 1.10 at -t 2, and Aqua passes.

🤖 Generated with Claude Code

…singular status

- Reading K.p, K.q or K.Rs before factoring crashed in libklu.
- klu_analyze! with permutations that are not zero-based crashed in libklu. The test
  for this never reached libklu, as klu_analyze! returns early on an analyzed object.
- Solves and reading the factors reset common.status, so a singular factorization
  reported issuccess(F) == true afterwards, even after just printing it.
- klu(...; check = false) threw on an invalid pattern.
- klu! after klu(A; full_factor = false) failed and left the object unusable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.26%. Comparing base (e606b12) to head (e010d8b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #53      +/-   ##
==========================================
+ Coverage   69.29%   71.26%   +1.97%     
==========================================
  Files           2        2              
  Lines         622      630       +8     
==========================================
+ Hits          431      449      +18     
+ Misses        191      181      -10     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ViralBShah
ViralBShah merged commit 56b9e81 into main Oct 30, 2026
8 checks passed
@ViralBShah
ViralBShah deleted the fix-unfactored-and-status branch October 30, 2026 21:17
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