Repository navigation
fix: guard against empty band UB in lbl.equivalent_lines binding - #1184
Merged
Merged
Conversation
The equivalent_lines Python binding dereferenced band.front() before validating the band, causing undefined behavior for empty bands. Add an ARTS_USER_ERROR guard for the empty-band case, matching the error style of the C++ callee.
Member
Author
|
@riclarsson Is throwing an error ok or would you prefer a noop on an empty band input in the python interface for std::pair{ComplexTensor3(0, 0, 0), ComplexTensor3(0, 0, 0)}
# or
std::pair{ComplexTensor3(M, 0, 0), ComplexTensor3(M, 0, 0)}to match the type of the later return. |
Contributor
|
@olemke Explain tomorrow |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
lbl.equivalent_linesPython binding accessedband.front()without checking that the band was non-empty, so passing an empty absorption band invoked undefined behavior and crashed the interpreter instead of reporting a usable error. This PR adds an explicit validation step so that empty bands raise a properARTS_USER_ERROR, turning a hard crash into a catchable Python exception.Changes
src/python_interface/py_lbl.cpp: In thelbl.equivalent_linesbinding, the band size is now checked first and anARTS_USER_ERROR("Cannot use an empty band in equivalent_lines")is thrown for empty bands, before anyband.front()access. Thelbl::voigt::ecs::ComputeDataconstruction was also moved below the validation so no solver state is built for an invalid call.