Repository navigation
Commit 30446ea
fix(cuda): bound dictionary gathers by the dictionary length (#10915)
## Summary
- Tracking Issue: #10914
The standalone dictionary kernels in `dict.cu` gathered
`values[codes[i]]` for every row. Nullable codes can hold any value at
null positions (`DictArray::try_new` doesn't bound-check them), so these
gathers read outside the dictionary. The fused planner already rejects
nullable-code dictionaries for this reason and sends them to these
kernels. Develop's own fuzzer, extended here, crashes on this within 71k
runs.
## Changes
- `dict.cu`: every kernel (primitive, decimal, bool and the 16-byte view
gather) takes `values_len`. A code at or beyond it writes a zero value.
In a valid array only null positions can hold such a code, so the zero
is never observed.
- `dict.rs` and `benches/dynamic_dispatch_cuda.rs`: pass `values_len` at
every launch.
- Tests (12), each compared with the expected result through
`assert_arrays_eq`:
- out-of-range codes under nulls for string, decimal, bool and primitive
values, with codes up to `u32::MAX` and `u64::MAX`;
- the dictionary the fuzzer crashed on (one u8 value, null code
3,960,089,894);
- device-resident codes with nullable values and codes;
- all-null codes;
- slices across 1,023/1,024/1,025 and 2,047/2,048;
- u16 codes with 65,536 values and u32 codes with 70,000;
- empty, 12-, 13- and 4,097-byte strings;
- non-UTF-8 binary values.
- `fuzz/src/gpu/mod.rs`: `compress_gpu` also generates string and binary
dictionaries, dictionaries with arbitrary u8/u16/u32 codes under nulls,
and strings compressed with the CUDA preset.
Evidence (A40, CUDA 13.0):
| Check | develop's kernels | this PR |
|---|---|---|
| 5 bug tests: out-of-range codes under nulls (string, decimal, bool,
primitive) and the fuzzer's input | 5 fail with
`CUDA_ERROR_ILLEGAL_ADDRESS` | 5 pass |
| 7 edge-case tests (all-null codes, block-boundary slices, full u16/u32
ranges, inline boundary, binary, device codes) | pass | 7 pass |
| `compute-sanitizer --tool memcheck` on the 6 out-of-range tests | 1-2
errors each, `Invalid __global__ read` of 1, 8 or 16 bytes | 0 errors |
| `compress_gpu` fuzz (CI flags, ASAN, empty corpus) | crash after
70,941 runs, `CUDA_ERROR_ILLEGAL_ADDRESS` | 100,000 runs in 283 s, 0
crashes |
| `vortex-cuda` lib suite | — | 719 passed, 0 failed |
Under nsys, the bounds check costs nothing measurable on numeric
dictionaries: 1.574 vs 1.563 ms per iteration on CMSprovider and 0.825
vs 0.832 ms on taxi.
On develop's kernels the `u32::MAX`/`u64::MAX` tests leave the CUDA
context in a sticky `CUDA_ERROR_ILLEGAL_ADDRESS` state. Run in one
process, they also fail the unrelated tests that follow, about 336 of
them. A regression of this fix would show up the same way, as a wall of
failures led by these tests.
Everything in the table ran on this PR alone, except the develop fuzz
crash: that ran develop's kernels under this PR's extended fuzz target.
## AI assistance
Developed with Claude Code (Claude Opus 5.5), which wrote most of the
code, tests and this description under my direction. I reviewed the diff
and the measurements.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Signed-off-by: Tanish Gudise <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Alexander Droste <[email protected]>1 parent 500f8b1 commit 30446ea
4 files changed
Lines changed: 334 additions & 8 deletions
File tree
- fuzz/src/gpu
- vortex-cuda
- benches
- kernels/src
- src/kernel/arrays
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
16 | 21 | | |
| 22 | + | |
17 | 23 | | |
18 | 24 | | |
| 25 | + | |
| 26 | + | |
19 | 27 | | |
20 | 28 | | |
21 | 29 | | |
| |||
28 | 36 | | |
29 | 37 | | |
30 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
31 | 42 | | |
32 | 43 | | |
33 | 44 | | |
34 | 45 | | |
35 | | - | |
36 | | - | |
| 46 | + | |
37 | 47 | | |
| 48 | + | |
38 | 49 | | |
39 | 50 | | |
40 | 51 | | |
| |||
58 | 69 | | |
59 | 70 | | |
60 | 71 | | |
| 72 | + | |
61 | 73 | | |
62 | 74 | | |
63 | 75 | | |
64 | 76 | | |
65 | 77 | | |
66 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
67 | 147 | | |
68 | | - | |
| 148 | + | |
69 | 149 | | |
70 | 150 | | |
71 | 151 | | |
| |||
80 | 160 | | |
81 | 161 | | |
82 | 162 | | |
83 | | - | |
| 163 | + | |
84 | 164 | | |
85 | 165 | | |
86 | 166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
625 | 625 | | |
626 | 626 | | |
627 | 627 | | |
| 628 | + | |
628 | 629 | | |
629 | 630 | | |
630 | 631 | | |
| 632 | + | |
631 | 633 | | |
632 | 634 | | |
633 | 635 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
| 18 | + | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
| |||
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
23 | | - | |
| 27 | + | |
24 | 28 | | |
25 | 29 | | |
26 | 30 | | |
| |||
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
| 46 | + | |
42 | 47 | | |
43 | 48 | | |
44 | 49 | | |
| |||
53 | 58 | | |
54 | 59 | | |
55 | 60 | | |
56 | | - | |
| 61 | + | |
57 | 62 | | |
58 | 63 | | |
59 | 64 | | |
| |||
69 | 74 | | |
70 | 75 | | |
71 | 76 | | |
| 77 | + | |
72 | 78 | | |
73 | | - | |
| 79 | + | |
74 | 80 | | |
75 | 81 | | |
76 | 82 | | |
| |||
84 | 90 | | |
85 | 91 | | |
86 | 92 | | |
| 93 | + | |
87 | 94 | | |
88 | 95 | | |
89 | | - | |
| 96 | + | |
90 | 97 | | |
91 | 98 | | |
92 | 99 | | |
| |||
0 commit comments