Commit 754eb3d
Guard the sent-dict mirror against int overflow
The I/O thread's lifetime-monotonic symbol-dictionary mirror is sized with
int math: accumulateSentDict passed sentDictBytesLen + regionBytes (an int
sum) to ensureSentDictCapacity, and the grow step doubled capacity*2, also
int. On a pathological, very-high-cardinality connection the sum overflows
negative -- so the capacity check passes and copyMemory scribbles past the
buffer (silent heap corruption) -- and capacity*2 overflows negative near
1 GB, degrading the doubling to exact-fit reallocs. Reaching this needs
~200M+ distinct symbols on one connection, far past any real workload, but
the failure mode is silent corruption.
ensureSentDictCapacity now takes a long, the caller passes a long sum, and
the method throws a LineSenderException above an int-addressable ceiling
(Integer.MAX_VALUE - 8) instead of overflowing, growing in long math
clamped to that ceiling. Defensive only -- not reachable at realistic
symbol cardinality, so there is no scale test.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 282ac09 commit 754eb3d
1 file changed
Lines changed: 24 additions & 5 deletions
File tree
- core/src/main/java/io/questdb/client/cutlass/qwp/client/sf/cursor
Lines changed: 24 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
136 | 142 | | |
137 | 143 | | |
138 | 144 | | |
| |||
2035 | 2041 | | |
2036 | 2042 | | |
2037 | 2043 | | |
2038 | | - | |
| 2044 | + | |
| 2045 | + | |
| 2046 | + | |
| 2047 | + | |
| 2048 | + | |
2039 | 2049 | | |
2040 | 2050 | | |
2041 | 2051 | | |
2042 | 2052 | | |
2043 | 2053 | | |
2044 | | - | |
| 2054 | + | |
2045 | 2055 | | |
2046 | 2056 | | |
2047 | 2057 | | |
2048 | | - | |
2049 | | - | |
2050 | | - | |
| 2058 | + | |
| 2059 | + | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
2051 | 2070 | | |
2052 | 2071 | | |
2053 | 2072 | | |
| |||
0 commit comments