Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qessz-008Yvl-Js for pgsql-bugs@arkaria.postgresql.org; Sat, 09 Sep 2023 08:00:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qessy-00FaVt-6b for pgsql-bugs@arkaria.postgresql.org; Sat, 09 Sep 2023 08:00:07 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qessx-00FaVe-R4 for pgsql-bugs@lists.postgresql.org; Sat, 09 Sep 2023 08:00:07 +0000 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qessu-003Zkl-4v for pgsql-bugs@lists.postgresql.org; Sat, 09 Sep 2023 08:00:05 +0000 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-501bd164fbfso4475849e87.0 for ; Sat, 09 Sep 2023 01:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694246402; x=1694851202; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=i6J0D72E/FMBFWuw2g/Y7oB5aL+GV0c17fp3clpw0D8=; b=DWPMM6E2dkfJguRtNMXb2VgCB563DSznjUNuRmhRmEHtdon6VcCb21HxRAI1jCAb1f Y9w7QC7b2rfjRK0GB9pRUZShm/QMSoHIk759zz+RQeRRgAkGPh/P2n+eA7ceDgC4fFTS 2JnrHXcbrPuLVS3ytTupUXvoGY+DiyjsV7g7Puyr9Ws+rF5+0i3Ij8rVAiKYLQCNIasY TRkpYUrm7lXU9nvdHarUrr+TZBS0RP87WJ9LZuy3Q4S3lTqnmU60Gg/chspO16mn6ad4 mVcGBZxJljIRxCNnil6oTifAihrWeg26E76wzj2YpVGCa5MFyFskkkNCgsWrkf6INcYv FOfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694246402; x=1694851202; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=i6J0D72E/FMBFWuw2g/Y7oB5aL+GV0c17fp3clpw0D8=; b=tAngV8CGTThYdhPlby41B47J1Cj8oqj8UBVYEOydMtUf4O1gal++bDAcQ746Le+iiH hbpT+DvNpmUeiIDXBrXeKrBedf6Z0aVjjRzaq5DdEGVJ4BQ1hx27dVmiSEGxLRFMXU3T JxX41INfMnTYGySTJIkDGhvcPJHK5r4GjTY5nVEH2ex2lYfI2sYX1vXkMaOa4r5shPWh E9m+9BDHttV3QN+0ywU31DE49DGb/sABr1o/+ORoc/CALOZ0o4wRagy7KIYYaWB+6cex r7LRJZNQCjqbmyCyjFHwPTe2pWsU3mP75fLKqaj3Tsez0ncPh8qrPak0W2p82XhIV8nR naLA== X-Gm-Message-State: AOJu0Ywv8hOfEG0M2FJKa8c6T8JAScRMxQoduWQmRrWeEXdhFLBPQNwC 343O2VdM5VIKyjJwUENORXA= X-Google-Smtp-Source: AGHT+IFbAs00jWkStPzvg5tRAxOJJlBONZl9gIClvUrZ8WGOV8JODmPm5c0XXOtcNmjKfvFdtw8R/A== X-Received: by 2002:ac2:4ac7:0:b0:4fe:3364:6c20 with SMTP id m7-20020ac24ac7000000b004fe33646c20mr3466274lfp.16.1694246402316; Sat, 09 Sep 2023 01:00:02 -0700 (PDT) Received: from [1.0.0.7] ([178.155.23.13]) by smtp.gmail.com with ESMTPSA id u4-20020ac25184000000b004fe21720b48sm533454lfi.279.2023.09.09.01.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 09 Sep 2023 01:00:01 -0700 (PDT) Message-ID: Date: Sat, 9 Sep 2023 11:00:00 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: BUG #17855: Uninitialised memory used when the name type value processed in binary mode of Memoize Content-Language: en-US To: David Rowley , pgsql-bugs@lists.postgresql.org References: <17855-5f523e0f9769a566@postgresql.org> From: Alexander Lakhin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi David, 25.03.2023 08:32, David Rowley wrote: > The attached is just a draft so far. It'll need more comments to > document what the code is all about. I don't want to spend too much > time on it if this isn't going to be the final solution. I've stumbled upon this issue one more time. With a query like this: CREATE TABLE t(id integer, node name); CREATE INDEX t_id_node_idx ON t(id, node); INSERT INTO t VALUES (1, 'node1'); EXPLAIN SELECT array_agg(node ORDER BY node) AS node_list FROM t GROUP BY id; SELECT array_agg(node ORDER BY node) AS node_list FROM t GROUP BY id; I get (on REL_16_STABLE):                                       QUERY PLAN --------------------------------------------------------------------------------------  GroupAggregate  (cost=0.15..67.65 rows=200 width=36)    Group Key: id    ->  Index Only Scan using t_id_node_idx on t (cost=0.15..60.90 rows=850 width=68) (Note that this time the error is triggered without the Memoize node.) ==00:00:00:04.385 3941088== Uninitialised byte(s) found during client check request ==00:00:00:04.385 3941088==    at 0x1F0CF7: printtup (printtup.c:349) ==00:00:00:04.385 3941088==    by 0x410521: ExecutePlan (execMain.c:1701) ==00:00:00:04.385 3941088==    by 0x4106B3: standard_ExecutorRun (execMain.c:365) ==00:00:00:04.385 3941088==    by 0x41078D: ExecutorRun (execMain.c:309) ==00:00:00:04.385 3941088==    by 0x5FAC9A: PortalRunSelect (pquery.c:924) ==00:00:00:04.385 3941088==    by 0x5FC63B: PortalRun (pquery.c:768) ==00:00:00:04.385 3941088==    by 0x5F85F3: exec_simple_query (postgres.c:1274) ==00:00:00:04.385 3941088==    by 0x5FA593: PostgresMain (postgres.c:4637) ==00:00:00:04.385 3941088==    by 0x5514A2: BackendRun (postmaster.c:4464) ==00:00:00:04.385 3941088==    by 0x554658: BackendStartup (postmaster.c:4192) ==00:00:00:04.385 3941088==    by 0x5547F6: ServerLoop (postmaster.c:1782) ==00:00:00:04.385 3941088==    by 0x555D26: PostmasterMain (postmaster.c:1466) ==00:00:00:04.385 3941088==  Address 0x1121ecdc is 36 bytes inside a block of size 88 client-defined ==00:00:00:04.385 3941088==    at 0x77EDA5: palloc0 (mcxt.c:1282) ==00:00:00:04.385 3941088==    by 0x62B6BC: construct_md_array (arrayfuncs.c:3528) ==00:00:00:04.385 3941088==    by 0x631013: makeMdArrayResult (arrayfuncs.c:5427) ==00:00:00:04.385 3941088==    by 0x6242AF: array_agg_finalfn (array_userfuncs.c:858) ==00:00:00:04.385 3941088==    by 0x4247F5: finalize_aggregate (nodeAgg.c:1120) ==00:00:00:04.385 3941088==    by 0x42620A: finalize_aggregates (nodeAgg.c:1361) ==00:00:00:04.385 3941088==    by 0x426E71: agg_retrieve_direct (nodeAgg.c:2520) ==00:00:00:04.385 3941088==    by 0x4272B9: ExecAgg (nodeAgg.c:2180) ==00:00:00:04.385 3941088==    by 0x417EE1: ExecProcNodeFirst (execProcnode.c:464) ==00:00:00:04.385 3941088==    by 0x4104F0: ExecProcNode (executor.h:273) ==00:00:00:04.385 3941088==    by 0x4104F0: ExecutePlan (execMain.c:1670) ==00:00:00:04.385 3941088==    by 0x4106B3: standard_ExecutorRun (execMain.c:365) ==00:00:00:04.385 3941088==    by 0x41078D: ExecutorRun (execMain.c:309) ==00:00:00:04.385 3941088== With your last patch applied I see no this valgrind complaint. Maybe it makes sense to register the proposed patch on the commitfest at least to keep it in sight? Best regards, Alexander Lakhin