Skip to content

Commit d3bbc4b

Browse files
committed
Add valgrind suppressions for wcsrtombs optimizations
wcsrtombs (called through wchar2char from common functions like lower, upper, etc.) uses various optimizations that may look like access to uninitialized data, triggering valgrind reports. For example AVX2 instructions load data in 256-bit chunks, and gconv does something similar with 32-bit chunks. This is faster than accessing the bytes one by one, and the uninitialized part of the buffer is not actually used. So suppress the bogus reports. The exact stack depends on possible optimizations - it might be AVX, SSE (as in the report by Aleksander Alekseev) or something else. Hence the last frame is wildcarded, to deal with this. Backpatch all the way back to 9.4. Author: Tomas Vondra Discussion: https://www.postgresql.org/message-id/flat/90ac0452-e907-e7a4-b3c8-15bd33780e62%402ndquadrant.com Discussion: https://www.postgresql.org/message-id/20180220150838.GD18315@e733.localdomain
1 parent 37afc07 commit d3bbc4b

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/tools/valgrind.supp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,39 @@
212212
Memcheck:Cond
213213
fun:PyObject_Realloc
214214
}
215+
216+
# wcsrtombs uses some clever optimizations internally, which to valgrind
217+
# may look like access to uninitialized data. For example AVX2 instructions
218+
# load data in 256-bit chunks, irrespectedly of wchar length. gconv does
219+
# somethink similar by loading data in 32bit chunks and then shifting the
220+
# data internally. Neither of those actually uses the uninitialized part
221+
# of the buffer, as far as we know.
222+
#
223+
# https://www.postgresql.org/message-id/90ac0452-e907-e7a4-b3c8-15bd33780e62@2ndquadrant.com
224+
225+
{
226+
wcsnlen_optimized
227+
Memcheck:Cond
228+
...
229+
fun:wcsrtombs
230+
fun:wcstombs
231+
fun:wchar2char
232+
}
233+
234+
{
235+
wcsnlen_optimized_addr32
236+
Memcheck:Addr32
237+
...
238+
fun:wcsrtombs
239+
fun:wcstombs
240+
fun:wchar2char
241+
}
242+
243+
{
244+
gconv_transform_internal
245+
Memcheck:Cond
246+
fun:__gconv_transform_internal_utf8
247+
fun:wcsrtombs
248+
fun:wcstombs
249+
fun:wchar2char
250+
}

0 commit comments

Comments
 (0)