From d883c9609832f2418ddcbc02d5cd3af2b47825b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emel=20=C5=9Eim=C5=9Fek?= Date: Tue, 11 Apr 2023 21:24:33 +0300 Subject: [PATCH] When creating a HTAB we need to use HASH_COMPARE flag in order to set a user defined comparison function. (#6845) DESCRIPTION: Fixes memory errors, caught by valgrind, of type "conditional jump or move depends on uninitialized value" When running Citus tests under Postgres with valgrind, the test cases calling into `NonBlockingShardSplit` function produce valgrind errors of type "conditional jump or move depends on uninitialized value". The issue is caused by creating a HTAB in a wrong way. HASH_COMPARE flag should have been used when creating a HTAB with user defined comparison function. In the absence of HASH_COMPARE flag, HTAB falls back into built-in string comparison function. However, valgrind somehow discovers that the match function is not assigned to the user defined function as intended. Fixes #6835 (cherry picked from commit e7a25d82c98df8ffea1508514972e217b034fc14) --- src/backend/distributed/operations/shard_split.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/distributed/operations/shard_split.c b/src/backend/distributed/operations/shard_split.c index 564e9420d..e2578c04c 100644 --- a/src/backend/distributed/operations/shard_split.c +++ b/src/backend/distributed/operations/shard_split.c @@ -1810,7 +1810,7 @@ CreateWorkerForPlacementSet(List *workersForPlacementList) /* we don't have value field as it's a set */ info.entrysize = info.keysize; - uint32 hashFlags = (HASH_ELEM | HASH_FUNCTION | HASH_CONTEXT); + uint32 hashFlags = (HASH_ELEM | HASH_FUNCTION | HASH_CONTEXT | HASH_COMPARE); HTAB *workerForPlacementSet = hash_create("worker placement set", 32, &info, hashFlags);