Skip to content

LPWrapper::solve() return status is discarded at every C++ call site, turning solver failures into silent all-zero results #9944

Closed

Description

@timosachsenberg

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_intopt returns 0 on success; non-zero is GLP_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

  1. added a commit that references this issue on Aug 25, 2026
    3184a1a
  2. added a commit that references this issue on Aug 28, 2026
    4cd0769
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions