Repository navigation
Conversation
The element access of CPyWrapperMatrixView, CPyWrapperMarkerMatrixView and CPyWrapper3DMatrixView checks zero-based indices with "index > extent", so the first index past the end passes the check. For example, driver.Coordinates()(nPoint, 0) or Solution(iSolver)(0, nVar) returns data instead of raising the "out of bounds" error: - a column index equal to the number of columns reads or writes the first element of the next row (Set with a list one value too long does the same); - a row index equal to the number of rows reads or writes past the end of the buffer; - for the marker views, a vertex index equal to the number of vertices dereferences a pointer past the vertex array and crashes. Compare with ">=" in the three const Access functions. The non-const Access functions and every Get/Set/operator() of the views go through them, so this covers all entry points. Results do not change: valid indices pass the check as before, and no solver path uses these views.
Contributor
|
Thanks, do you have a testcase that failed and now passes because of the fix, and that can be added to the regression tests? |
Author
|
Thanks. Not yet, because SU2_MPI::Error ends the process, so a unit test cannot catch the error. I can add a py_wrapper regression test: it runs a few iterations of a small case, then accesses each view with the first index past the end in a separate process and checks that this process stops with the "out of bounds" error. The last valid index must still return the value that was set. On develop the test fails, because these accesses return data without an error. With the fix it passes. I would add it to serial_regression.py. Is that ok for you? |
This branch has not been deployed
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.
Proposed Changes
The Python matrix views check zero-based indices with
index > extent. The first index past the end passes this check. For example,driver.Solution(iSolver)(0, nVar)returns the first value of the next row and gives no error. A row index equal to the number of rows reads or writes past the end of the buffer. On a marker view it causes a segmentation fault.This PR changes
>to>=in the threeAccessfunctions ofCPyWrapperMatrixView.hpp. AllGet,Setandoperator()forms use these functions. Valid indices work as before. No solver path uses the views, so results do not change.I added my name to
AUTHORS.md.Related Work
No issue. I found the defect when I used the Python wrapper.
PR Checklist
pre-commit run --allto format old commits.SU2_MPI::Errorends the process, so a unit test cannot catch the error.Tests
--warnlevel=3: primal and adjoint, with and without MPI, no new warnings.develop.