-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add assert to ensure using non-overlapping memory regions #3983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.x
Are you sure you want to change the base?
Conversation
…warpaffine function
@asmorkalov Should this be a documentation issue? e.g. This function does not support in place operations. I've been looking through to find a convention for dealing with this. I've found functions which
But I haven't found the consistent approach that the original issue implies
Would it be better in this PR to document that the function does not support in place operations with a simple assert
|
I think the suggestion to document that this function is not meant to be used inplace and combining it with an assertion is the best way forward. |
I agree but I would take it one step futher. I don't think we should be checking to see if the source and destination are overlapping just that they are not the same for the reason you mentioned
If a user has a source and destination which are not equal but are overlapping then they likely have far bigger issues with their program and an assert on overlap is not going to help them out. |
Fair point! I've simplified it to be an equality check now, and removed all the overlap logic. |
@cudawarped Thanks a lot for the investigation. You are right, there is no generic rule. Several asserts and copyTo calls we added as ad-hoc solution for some tickets. Different decisions were done depending on context: what the function logic and how it's already used to not break existing code. I would say that current solution with docs and assert is good enough. |
This pr addresses this issue: opencv/opencv#27429
where the user did not realize that the warpaffine function requires non-overlapping src and dst memory regions.
The code now compares the input memory regions and asserts that they do not overlap. There is also a test for this functionality.
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.