-
Notifications
You must be signed in to change notification settings - Fork 891
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
Fix concurrent_unordered_map to prevent accessing padding bits in pair_type #8348
Merged
rapids-bot
merged 11 commits into
rapidsai:branch-21.08
from
davidwendt:bug-hashmap-insert
Jun 2, 2021
Merged
Fix concurrent_unordered_map to prevent accessing padding bits in pair_type #8348
rapids-bot
merged 11 commits into
rapidsai:branch-21.08
from
davidwendt:bug-hashmap-insert
Jun 2, 2021
Conversation
This file contains 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
davidwendt
added
bug
Something isn't working
2 - In Progress
Currently a work in progress
libcudf
Affects libcudf (C++/CUDA) code.
non-breaking
Non-breaking change
labels
May 25, 2021
davidwendt
added
3 - Ready for Review
Ready for review by team
and removed
2 - In Progress
Currently a work in progress
labels
May 25, 2021
rerun tests |
vuule
approved these changes
May 26, 2021
jrhemstad
approved these changes
May 26, 2021
ttnghia
approved these changes
May 28, 2021
harrism
added
5 - Ready to Merge
Testing and reviews complete, ready to merge
and removed
3 - Ready for Review
Ready for review by team
labels
May 31, 2021
Codecov Report
@@ Coverage Diff @@
## branch-21.08 #8348 +/- ##
===============================================
Coverage ? 82.83%
===============================================
Files ? 109
Lines ? 17901
Branches ? 0
===============================================
Hits ? 14828
Misses ? 3073
Partials ? 0 Continue to review full report at Codecov.
|
@gpucibot merge |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
5 - Ready to Merge
Testing and reviews complete, ready to merge
bug
Something isn't working
libcudf
Affects libcudf (C++/CUDA) code.
non-breaking
Non-breaking change
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
concurrent_unordered_map
class uses athrust::pair
type internally to manage key/value pairs. There is also an also anpair_packer
utility that will pack the pair into a single type (uint32 or uint64) to better utilize theatomicCAS
for storing the pair. The code also includes a path for cases when thethrust::pair
is not packable.The
is_packable
tests to make sure both pairs are integer types and can be packed in either a single uint32 or uint64 type. Unfortunately, if the types are different sizes (e.g.thrust::pair<uint64_t, uint32_t>
) the pair-type also contains padding bits. This resulted in a crash insemi_left_join
which resulted in a pair type ofthrust::pair<uint32_t,bool>
. Referencing the single packed value therefore included padding bits which is undefined behavior.Debug session showing packed values with non-zero padding bits
[New Thread 0x7f05725fd700 (LWP 6311)]
[New Thread 0x7f0571c77700 (LWP 6312)]
[Switching focus to CUDA kernel 0, grid 5, block (0,0,0), thread (0,0,0), device 0, sm 0, warp 0, lane 0]
Thread 1 "map_test" hit Breakpoint 1, concurrent_unordered_map<int, bool, cudf::row_hasher<default_hash, true>, cudf::row_equality_comparator, default_allocator<thrust::pair<int, bool> > >::attempt_insert<thrust::pair<int, bool> > (this=0x7f0574fffb08, insert_location=0x7f0542e00448, insert_pair=0x7f0574fff9f8)
at /cudf/cpp/build/../src/hash/concurrent_unordered_map.cuh:283
283 if (old.packed == unused.packed) { return insert_result::SUCCESS; }
///// expected these 2 values to be equal but the random padding bits makes this false
(cuda-gdb) p old.packed
$1 = 6442450943
(cuda-gdb) p unused.packed
$2 = 8430733011321880575
(cuda-gdb) p old.pair.first
$3 = 2147483647
(cuda-gdb) p old.pair.second
$4 = true
(cuda-gdb) p unused.pair.first
$5 = 2147483647
(cuda-gdb) p unused.pair.second
$6 = true
(cuda-gdb) p/x unused.packed
$9 = 0x74fffb017fffffff
(cuda-gdb) p/x old.packed
$10 = 0x17fffffff
(cuda-gdb) p unused
$11 = {packed = 8430733011321880575, pair = {first = 2147483647, second = true}}
(cuda-gdb) p/x unused.pair.first
$12 = 0x7fffffff
(cuda-gdb) p/x unused.pair.second
$13 = 0x1
(cuda-gdb)
(cuda-gdb) p old
$14 = {packed = 6442450943, pair = {first = 2147483647, second = true}}
(cuda-gdb) p/x old.pair.first
$15 = 0x7fffffff
(cuda-gdb) p/x old.pair.second
$16 = 0x1
(cuda-gdb)
This PR solves this by adding a size check to the current
is_packable()
. The C++17 std::has_unique_object_representations is used here to ensure no padding bits are in thepair_type
.