Fix integer overflow in reconstruction cython code#7938
Merged
stefanv merged 2 commits intoscikit-image:mainfrom Nov 10, 2025
Merged
Fix integer overflow in reconstruction cython code#7938stefanv merged 2 commits intoscikit-image:mainfrom
stefanv merged 2 commits intoscikit-image:mainfrom
Conversation
While scikit-image#6342 added code to support passing int64 arrays to reconstruction_loop, the local variables that hold values from these arrays are still 32-bit. This change uses the appropriate fused int types instead.
Increases the readability. Naive profiling suggests that memoryviews are also slightly faster. We can use those here, because `negative_indices=False` is equivalent to `@cython.wraparound(False)` [1]. Also consistently use the same dtype setup here, either `np_ints` or `np_uints` since these values are added / assigned to each other. Might save some unnecessary conversations? [1] https://cython.readthedocs.io/en/3.1.x/src/tutorial/numpy.html#buffer-options
Contributor
Author
|
Confirmed -- your version works fine for me. |
Member
|
Thanks @jmuhlich! |
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.
Description
I was experiencing segfaults in the reconstruction_loop cython code when reconstruction was called with very large images, even after #6342 added code to support passing int64 arrays. I discovered that the local variables that hold the values from these arrays are still 32-bit. This change uses the appropriate fused int types instead.
Checklist
./doc/examplesfor new featuresRelease note
For maintainers and optionally contributors, please refer to the instructions on how to document this PR for the release notes.