Use memmove in PODArray::insert to handle memory overlapping.#24271
Merged
kitaisreal merged 1 commit intoClickHouse:masterfrom May 20, 2021
Merged
Use memmove in PODArray::insert to handle memory overlapping.#24271kitaisreal merged 1 commit intoClickHouse:masterfrom
kitaisreal merged 1 commit intoClickHouse:masterfrom
Conversation
Member
|
We need to cover this case in unit test (see |
Contributor
Author
|
Hi alexey, from spec memcpy's behavior is undefined if the src and dst range are overlapping. However from here:
And I tested locally they have the same behavior (gcc-9, Ubuntu-12.04). I wonder how to cover this case while avoiding intrusive code change (e.g. do some tricks under NDEBUG), do you have any idea? |
Contributor
|
@fuzhe1989 actually asan can check memcpy overlap regions, will update gtest_pod_array to check that case. |
This was referenced May 20, 2021
Merged
Merged
kitaisreal
added a commit
that referenced
this pull request
May 20, 2021
Backport #24271 to 21.5: Use memmove in PODArray::insert to handle memory overlapping.
kitaisreal
added a commit
that referenced
this pull request
May 20, 2021
Backport #24271 to 21.3: Use memmove in PODArray::insert to handle memory overlapping.
kitaisreal
added a commit
that referenced
this pull request
May 20, 2021
Backport #24271 to 21.4: Use memmove in PODArray::insert to handle memory overlapping.
kitaisreal
added a commit
that referenced
this pull request
May 21, 2021
Backport #24271 to 21.6: Use memmove in PODArray::insert to handle memory overlapping.
xinyiZzz
added a commit
to apache/doris
that referenced
this pull request
Jun 3, 2024
1. Add PODArray ut 2. pick ClickHouse/ClickHouse#21533 3. pick ClickHouse/ClickHouse#21678 4. pick ClickHouse/ClickHouse#9498 5. pick ClickHouse/ClickHouse#7791 6. pick ClickHouse/ClickHouse#24271 7. if c_end_of_storage == null, allocated_bytes return 0. 8. Add some checks for DEBUG. 9. TODO: Adapt internal data structures to 512-bit era ClickHouse/ClickHouse#42564
dataroaring
pushed a commit
to apache/doris
that referenced
this pull request
Jun 4, 2024
1. Add PODArray ut 2. pick ClickHouse/ClickHouse#21533 3. pick ClickHouse/ClickHouse#21678 4. pick ClickHouse/ClickHouse#9498 5. pick ClickHouse/ClickHouse#7791 6. pick ClickHouse/ClickHouse#24271 7. if c_end_of_storage == null, allocated_bytes return 0. 8. Add some checks for DEBUG. 9. TODO: Adapt internal data structures to 512-bit era ClickHouse/ClickHouse#42564
seawinde
pushed a commit
to seawinde/doris
that referenced
this pull request
Jun 5, 2024
1. Add PODArray ut 2. pick ClickHouse/ClickHouse#21533 3. pick ClickHouse/ClickHouse#21678 4. pick ClickHouse/ClickHouse#9498 5. pick ClickHouse/ClickHouse#7791 6. pick ClickHouse/ClickHouse#24271 7. if c_end_of_storage == null, allocated_bytes return 0. 8. Add some checks for DEBUG. 9. TODO: Adapt internal data structures to 512-bit era ClickHouse/ClickHouse#42564
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.
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en
PODArray::insert will move a bunch of data forward to leave space for new items. The new memory range can be overlapping with the old memory range when bytes_to_move is larger than bytes_to_copy and use of memcpy here has undefined behavior.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Use memmove in PODArray::insert to handle memory overlapping.