Repository navigation
Conversation
…290) prop_type was typed as the Cython enum cea_property_type, so negative values raised OverflowError at the function boundary before the method's own ValueError allowlist check could run. Typed as plain int instead, with explicit casts at the four downstream C-call sites. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Widens the temperature-type dispatch to accept np.floating scalars and plain Python int, not just Python float, so values like arr[0] from a float32/float64 array no longer raise a spurious ValueError. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Raises a clear ValueError on a temperature array/list length mismatch instead of a raw IndexError (too few) or silent truncation (too many). Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
The new invalid-prop_type path leaks reac_weights. It is allocated before the property/pressure validation, while the try/finally that frees it starts only after the second allocation. Unsupported properties and missing-pressure errors therefore exit before cleanup. Could those checks move before allocation, or could cleanup start immediately after the first malloc?
Move the prop_type and pressure checks before the malloc so neither early-exit path can leak the buffer. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
@sylvesterkaczmarek Good catch — confirmed. Fixed by moving both validation checks ahead of the Verified:
Drafted with Claude's assistance
|
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
Rechecked 078e3ba. Both early validation paths now run before reac_weights is allocated, so unsupported property types and missing-pressure errors cannot leak the buffer. The full current build/test matrix is green, and the stress result confirms the leak is gone. My concern is resolved.
…#165) (#134) * Reconcile CONTRIBUTING.md and developer_guide.rst on GFE/pFUnit setup (#53) Both docs described a different, non-working procedure for getting pFUnit available; standardize on the extern/gfe (lowercase) path that actually matches .gitignore and scripts/develop.sh, add the missing build+install+CMAKE_PREFIX_PATH steps, and cross-link the two docs instead of duplicating divergent instructions. Also notes the current Windows pFUnit build limitation (#163). * Drop stale Windows-fails caveat now that #163 has a fix in progress See djkees#163 (fix landing in a separate PR). (cherry picked from commit 1f7ea1f)
Summary
Three small, related fixes to
Mixture.calc_property's input dispatch, all in the same ~20-line region ofsource/bind/python/CEA.pyx. Combined into one PR since they touch the same code and would otherwise conflict with each other if merged out of order as separate PRs. Supersedes #161 and #162, which covered the first two of these individually.Changes
prop_typeinconsistency:prop_typewas typed as the Cython enumcea_property_type, so a negative out-of-range value raised a Cython-internalOverflowErrorinstead of the method's ownValueErrorallowlist check. Changed the parameter to plainint, with explicit<cea_property_type>casts added at the four downstream C-call sites.float, so numpy floating scalars (e.g.np.float32, which doesn't subclassfloat) and plainintwere incorrectly rejected. Widened toisinstance(temperature, (float, int, np.floating)). Numpy integer scalars remain deliberately rejected.temperature[i]fori in range(nspecies)without checkinglen(temperature) == nspecies, so a too-short array crashed with a rawIndexErrorand a too-long array silently truncated with no error. Both dispatch blocks now check the length up front and raise a clearValueErrornaming the actual and expected counts.source/bind/python/tests/test_mixture.pygained the corresponding regression tests for all three (parametrized over the invalidprop_typesign, numpy/int scalar types, and length-mismatch direction × container type).Testing
make py-rebuildpytest source/bind/python/tests— 128 passedCompatibility / Numerical behavior
Only changes exception-raising/dispatch-acceptance behavior for already-invalid or already-broken inputs; no change to any previously-correct call path.
Drafted with Claude's assistance
ceamodule before being written, reproducing the original bug firstupstream/mainbase, confirming all 128 tests pass including the new regression tests for all three fixes🤖 Generated with Claude Code