Skip to content

[bug] EqSolver/RocketSolver/ShockSolver/DetonationSolver size getters (and version getters) silently discard ierr #201

Description

@djkees

Summary
EqSolver, RocketSolver, ShockSolver, and DetonationSolver's num_reactants/num_products/num_gas/num_condensed/num_elements/max_equations properties all call cea_*_get_size(...), assign the result to ierr, and return the output value without ever checking ierr. The same pattern applies to _version_major/_version_minor/_version_patch and set_log_level. Every other C-call site in CEA.pyx routes its ierr through _check_ierr(...); these are the only ones that don't.

Reproduction

  • Interface: Python
  • Minimal input / steps: Not reproducible as a live failure without an artificial C-side failure injection — this is a static-analysis finding from reading source/bind/python/CEA.pyx.
  • Command or API call used: e.g. EqSolver.num_reactants, RocketSolver.num_gas, cea._version_major()

Expected behavior
If cea_eqsolver_get_size (or the rocket/shock/detonation equivalents, or cea_version_major) returns a non-SUCCESS error code, the Python property/function should raise RuntimeError via _check_ierr, matching the error-handling convention used by every other binding call in the file.

Actual behavior
The error code is silently discarded and the (potentially uninitialized/stale) size_val/major/minor/patch is returned as if the call had succeeded. Confirmed by direct inspection — every other ierr = cea_...(...) assignment in CEA.pyx is immediately followed by a _check_ierr(ierr, ...) call except these:

  • EqSolver: CEA.pyx:1406,1420,1434,1448,1462,1476 (num_reactants, num_products, num_gas, num_condensed, num_elements, max_equations)
  • RocketSolver: CEA.pyx:2390,2404,2418,2432,2446 (same five size properties)
  • ShockSolver: CEA.pyx:3336,3350,3364,3378,3392
  • DetonationSolver: CEA.pyx:4243,4257,4271,4285,4299
  • _version_major/_version_minor/_version_patch: CEA.pyx:289,303,317
  • set_log_level: CEA.pyx:330

Environment

  • OS: Windows 11
  • CEA version/commit: 3.3.4 / 7ec0859
  • Compiler or Python version (if relevant): N/A (static finding, applies to any build)

Additional context
These calls are unlikely to fail in normal use (querying the size of an already-constructed solver, or querying the compiled-in version number, is close to infallible), which is likely why this was never caught by a test — but the inconsistency with the rest of the file's error-handling discipline is real, and a future refactor that does make these calls fallible (or a corrupted/partially-initialized solver object) would fail silently instead of raising.


Drafted with Claude's assistance

  • Confirmed via a targeted grep across source/bind/python/CEA.pyx for every ierr = cea_...(...) assignment, then checking whether a _check_ierr call follows — the getters/functions listed above are the only ones where it doesn't.
  • Checked gh issue list on djkees/cea before filing to confirm this isn't a duplicate (searched ierr, get_size).

Activity

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

    bugSomething isn't workingpriority: mediumReal gap or well-scoped improvement, not currently masking anything known-wrong

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions