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 1s1RY9-00CM5K-9D for pgsql-bugs@arkaria.postgresql.org; Mon, 29 Apr 2024 14: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 1s1RY6-00HMI8-Aa for pgsql-bugs@arkaria.postgresql.org; Mon, 29 Apr 2024 14: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 1s1RY6-00HMHz-1z for pgsql-bugs@lists.postgresql.org; Mon, 29 Apr 2024 14:00:06 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s1RY4-000c4B-KX for pgsql-bugs@lists.postgresql.org; Mon, 29 Apr 2024 14:00:05 +0000 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-516d3a470d5so5452655e87.3 for ; Mon, 29 Apr 2024 07:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714399203; x=1715004003; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=lbQkQR54CMUZJ5jSQn6YuSBV+XWy/Jd5y1x48nOa2RM=; b=LhLMlyyL8b1bR7x9UPAqz2XM9jMHNS0lkvS6Ti+lbk02Q9pE2m6Jp8S/HN7zd3SuD5 h6OyTzca85vV/AywO2vU4OKPzLAHMRwJLWkvJsnq66goIh9HbL/pQ6LCmjyi1v0dSkAB sdtD6NcnjZUQWPWvshhpgrgf2n9hZFrdqAWalgqZE/rB2Gt9mKn1VQK9k2z/gCsE5Dk6 fp6VixDmjyVeDCiLZM1NgraO0nDb+IKHmnoos1cJ2OLCioVbMHKdRCXOjk8IkQ+ApEPV K8pGHA7nu8t+9KcbWDAXWiFEKdlbrlfP/pNGyruLDzT4JfoCXLAhyGbjI+pWohVKEdOj ZNrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714399203; x=1715004003; h=content-transfer-encoding:in-reply-to:from:references:cc: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=lbQkQR54CMUZJ5jSQn6YuSBV+XWy/Jd5y1x48nOa2RM=; b=BOXv+duKqON6ztpoAulwQ0h4Rk1py7gk3T3uyPEyIru9CeaXgx/xCDXL34A7cjQZGY rqTXaKSgMib/FpLb1/74En1GGP7JFM8dsBL09YueTCDTDD/q3oYZCGuHTXgDY3Rz1OEV 3dgbaR7XtrUzp76m4HfRL4+mkt4GGJg87ma4ZP0fckM1P50SFJciZYo1z2aNrvcMRpkL cTI6SUS0VF4T8OyPxw+/G3gRpE11jcPdVDDS6hWIk/+zPS4IkK+qjsF+eYoAhkknyf0C A5ueb2LxwKZ7uS+cSC5nbFUvR0oWZGqdDBw17TY1xG0mPIY5Y4mIZ/z2026kLaG2zra6 HwvA== X-Forwarded-Encrypted: i=1; AJvYcCU8bEmhIr03bqDLTBrbsolfsLqqHriEgi8XdCN8ETHsMxGlJliG9z5uJpp3v+ho9wwtafOem93l6R5Ce/6Qvenn6A1UgNakGgEHL7B+5Rsw X-Gm-Message-State: AOJu0YwfHpW7Igl3m0Ak8BxmUxpmyEtZq7Q+rTCwyROfBURK2+30b/ft m3whehCUrhGU4LfNbb//JeqRawsY0IdI/gZIAAs5n6NGRsOmnVo9 X-Google-Smtp-Source: AGHT+IEWki1BjFzBgQ9XbzxjCLx9j0IBia0vOyK6U7kr90RnhEZkQjmrAEZhSfkKpqEpznylKjB0sg== X-Received: by 2002:a05:6512:3f7:b0:51b:5490:1b3a with SMTP id n23-20020a05651203f700b0051b54901b3amr5885822lfq.53.1714399202583; Mon, 29 Apr 2024 07:00:02 -0700 (PDT) Received: from [1.0.0.7] ([178.155.23.194]) by smtp.gmail.com with ESMTPSA id d30-20020a0565123d1e00b00516d0029383sm4106435lfv.28.2024.04.29.07.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 29 Apr 2024 07:00:02 -0700 (PDT) Message-ID: Date: Mon, 29 Apr 2024 17: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 Cc: Robert Haas , pgsql-bugs@lists.postgresql.org, Tom Lane References: <17855-5f523e0f9769a566@postgresql.org> <3943232.1714060238@sss.pgh.pa.us> 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 Hello David, 29.04.2024 03:54, David Rowley wrote: > On Fri, 26 Apr 2024 at 03:50, Tom Lane wrote: >> I do not like testing "atttypid == NAMEOID" one bit. As noted, >> that will fail on domains over name. It will also result in >> unnecessary work when reading non-btree indexes that contain >> name, since I don't think anything else has the same hack >> that btree name_ops does (grep for cstring in pg_opclass.dat). >> I think the correct thing is to see whether the index opclass >> for the column is btree name_ops. We don't seem to have an >> oid_symbol macro for that, but it shouldn't be hard to add, >> at least in HEAD. > On looking at the relcache code, I don't see anywhere that we store > the opclass Oid in RelationData. IndexSupportInitialize() only records > the opcfamily and opcintype. Assuming we can't add new fields to > RelationData in the backbranches, is there a reason why we can't check > for rd_opfamily of TEXT_BTREE_FAM_OID and rd_opcintype of NAMEOID? > > I've attached an updated patch that does it that way and also did a > round of commenting the code. With the v3 patch applied, `make check` fails for me under Valgrind: ok 66        + create_index                            33585 ms not ok 67    + create_index_spgist                     14446 ms # (test process exited with exit code 2) ==00:00:04:57.033 4152513== Invalid read of size 4 ==00:00:04:57.033 4152513==    at 0x456499: ExecInitIndexOnlyScan (nodeIndexonlyscan.c:657) ==00:00:04:57.033 4152513==    by 0x435EE6: ExecInitNode (execProcnode.c:225) ==00:00:04:57.033 4152513==    by 0x459780: ExecInitLimit (nodeLimit.c:477) ... ==00:00:04:57.033 4152513==  Address 0x73263b4 is 612 bytes inside a recently re-allocated block of size 1,024 alloc'd ==00:00:04:57.033 4152513==    at 0x4848899: malloc (vg_replace_malloc.c:381) ==00:00:04:57.033 4152513==    by 0x7A7DFC: AllocSetContextCreateInternal (aset.c:444) ==00:00:04:57.033 4152513==    by 0x775644: RelationInitIndexAccessInfo (relcache.c:1481) ==00:00:04:57.033 4152513==    by 0x775E4B: RelationBuildDesc (relcache.c:1207) ... ==00:00:04:57.033 4152513== ==00:00:04:57.033 4152513== Exit program on first error (--exit-on-first-error=yes) 2024-04-29 12:32:14.965 UTC postmaster[4109162] LOG:  server process (PID 4152513) exited with exit code 1 2024-04-29 12:32:14.965 UTC postmaster[4109162] DETAIL:  Failed process was running: SELECT p, dist FROM quad_point_tbl_ord_seq1 ORDER BY p <-> '0,0' LIMIT 10; The quad_point_tbl_ord_seq1 index is defined as CREATE INDEX ON quad_point_tbl_ord_seq1 USING spgist(p) INCLUDE(dist); Best regards, Alexander