Repository navigation
Description
LPWrapper::solve() returns the solver's status code, and every production call site in src/openms discards it:
| Call site | Code |
|---|---|
MRMFeatureSelector.cpp:99 |
problem.solve(param); |
MRMFeatureSelector.cpp:209 |
problem.solve(param); |
ILPDCWrapper.cpp:271 |
build.solve(param); |
ILPDCWrapper.cpp:436 |
build.solve(param); |
The return value is never assigned anywhere in the C++ codebase. Each of these reads the solution immediately afterwards via getColumnValue() (e.g. MRMFeatureSelector.cpp:100-105), so a solver that declined to solve is indistinguishable from one that returned an optimum of all zeros.
The pyOpenMS binding does return the status (bind_datastructures.cpp:520, documented :return: solver dependent), so Python callers can inspect it — C++ callers simply never do.
Why this matters: it converts a clean solver error into silent wrong data
This is not hypothetical — it is the mechanism behind the MRMFeatureSelector bug fixed in #9940.
On a GLPK build, MRMFeatureSelector's "exactly one feature per transition" constraint reached glp_set_row_bnds as GLP_DB with lb == ub. GLPK behaved correctly: it printed
glp_intopt: row 1: lb = 1, ub = 1; incorrect bounds
and returned GLP_EBOUND (4) from glp_intopt, which LPWrapper::solve() duly returned (LPWrapper.cpp:826). Nothing was solved, and the library said so.
Because the return value was discarded, optimize() went straight on to read getColumnValue() for every column, got 0.0 for all of them, and produced an empty feature selection. Library and pyOpenMS callers (e.g. MRMBatchFeatureSelector) therefore received no features and no error — output that looks plausible and is silently wrong.
Verified on a local GLPK build (-DLP_SOLVER=GLPK): MRMFeatureSelector_test terminated with SIGSEGV, and gdb placed the crash in std::vector<Feature>::operator[] called from the test main (MRMFeatureSelector_test.cpp:71) indexing the resulting empty FeatureMap — i.e. the crash is downstream of the empty result, not inside GLPK. A production caller that does not index out of range would get no crash at all — just silently empty output.
#9940 removed that particular trigger by typing the constraint FIXED (MRMFeatureSelector.cpp:96). The underlying hazard is unchanged: any future solver failure — infeasible model, time limit, iteration limit, out of memory — will produce the same silent all-zero result, on any of the three backends.
Suggested fix
Check the return value at the four call sites, or have LPWrapper::solve() / getStatus() signal failure reliably. The three backends report status differently, so a small normalisation inside LPWrapper is probably cleaner than four ad-hoc checks:
- GLPK —
glp_intoptreturns0on success; non-zero isGLP_EBOUND,GLP_ENOPFS,GLP_ETMLIM, … (LPWrapper.cpp:826) - CoinOr — returns
model.status()(LPWrapper.cpp:752) - HiGHS — returns
static_cast<Int>(HighsStatus)(LPWrapper.cpp:783)
Note that getStatus() is not currently a reliable substitute: it returns UNDEFINED unconditionally on the CoinOr path (LPWrapper.cpp:833).
At minimum, a log warning when solve() reports failure would have turned this from "silently empty results" into an actionable message.
Activity
[FIX] pyOpenMS: stop wrapping the low-level LPWrapper (relates to #9944)
Fix silent LP solver failures: make LPWrapper status reliable and che…
Document LP-solver failure modes left stale by the getStatus() fix
[FIX] pyOpenMS: stop wrapping the low-level LPWrapper
Merge pull request #9983 from OpenMS/claude/openms-issue-9944-l5qkfo
[FIX] LPWrapper: stop discarding solve() status, so solver failures a…