Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pFrPv-0000qe-Qw for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Jan 2023 06:50:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pFrPu-0004jw-O3 for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Jan 2023 06:50:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pFrPu-0004jn-CZ for pgsql-hackers@lists.postgresql.org; Thu, 12 Jan 2023 06:50:26 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pFrPr-0008Pa-SS for pgsql-hackers@lists.postgresql.org; Thu, 12 Jan 2023 06:50:25 +0000 Received: by mail-pg1-x541.google.com with SMTP id d10so12117395pgm.13 for ; Wed, 11 Jan 2023 22:50:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:subject:references:in-reply-to:message-id:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=bQ9hJio+ZveimWt2G7vY5CjDtMwep2qz1hdUhIqNlSM=; b=jF0kesvL/XPd1mt85aGzNtMdPBWPFknxbP7xiXjIgXLUWIKNDpj/MafkF4UwpwNHap nIQO2T0emSRAq6n4p19jmkbzqvo/3+Ps6fIxyQVacLioP6ZAEWo9TCT3VcmqCaCimd7j rSJLavQutv+9nvCwOW0CzicdzCaCeQW1dtjqC4Z8gd42ORZwGBI50AYPERxIPfenbvTv PWYo/pP1WUspMgBcTzzwDVfsOD/XOQjNqANpEyya5cjPNftKuMwtGf/BETMrbyHEKhfO myrttQqED/QmHj/MLbiy5k8QOEsTA2rqXoj5Oy0o6mbyJkrYyR9htP9lL2nlDPE7JyJF cbcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:subject:references:in-reply-to:message-id:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bQ9hJio+ZveimWt2G7vY5CjDtMwep2qz1hdUhIqNlSM=; b=1UurL3qU6YXsC6fZqUq9ygYT2plL2YYc+knzJmMKO3BOCdCRlOfiEc5Yroxzg+1snt IE42d34HcgIT5pjPicjynLswDR86n9sgOQdCSekPbL2UgqoBV1w8dqQH57x08BGvPeyx EF4h/CAVKidbyLXVchdPz05teo85JzHbWaFzak7GMLpbOFGP846Ma8O3tm31j0Ebr9c/ ObfQnRr+L2pCNK3Ii2E8wjHKPWSFU8NR/uM4tUq/1oaGPKKoTsqxkyYT17JGG+cEu/ui S0Xkh3wEU2BXZTPLfmDJFzBc+3xmLwOUBxJ+JLK26sKRwgtpFekK2U4O4lVjA/r3vn34 rY6Q== X-Gm-Message-State: AFqh2kr9ZY9JdrW9raqoEGa0f/CIC70pdiogc9Z8+ECHgKkuVHUvTVtq Wi+Bj2tFqs4ksRlG2aOOLfI8zOrGWe8= X-Google-Smtp-Source: AMrXdXv7vGY2BlAvb8N5Ki6lIwpkikgAKDqd7/32+7/4CMu2a/7SF/pn9AfuJRBZosdxDqL5FpS5qg== X-Received: by 2002:a62:640f:0:b0:581:f301:23fc with SMTP id y15-20020a62640f000000b00581f30123fcmr4553900pfb.12.1673506221181; Wed, 11 Jan 2023 22:50:21 -0800 (PST) Received: from [127.0.0.1] (60-249-3-227.hinet-ip.hinet.net. [60.249.3.227]) by smtp.gmail.com with ESMTPSA id 3-20020a621503000000b00581c741f95csm9293570pfv.46.2023.01.11.22.50.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jan 2023 22:50:20 -0800 (PST) Date: Thu, 12 Jan 2023 14:50:13 +0800 From: Zhang Mingli To: PostgreSQL Hackers Message-ID: <70ce9710-e9ed-4a25-a327-88de830b8cf6@Spark> In-Reply-To: <1c7954e4-1705-4855-a99d-c77bf426c3e7@Spark> References: <1c7954e4-1705-4855-a99d-c77bf426c3e7@Spark> Subject: Re: Fix condition in shm_toc and remove unused function shm_toc_freespace. X-Readdle-Message-ID: 70ce9710-e9ed-4a25-a327-88de830b8cf6@Spark MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="63bfadaa_b03e0c6_17004" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --63bfadaa_b03e0c6_17004 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, On Jan 12, 2023, 14:34 +0800, Zhang Mingli , wro= te: > Hi, hackers > > Some conditions in shm=5Ftoc=5Finsert and shm=5Ftoc=5Fallocate are bogu= s, like: > if (toc=5Fbytes + nbytes > total=5Fbytes =7C=7C toc=5Fbytes + nbytes = < toc=5Fbytes) > Remove the condition =60toc=5Fbytes + nbytes < toc=5Fbytes=60 and take = a sizeof(shm=5Fentry) into account in shm=5Ftoc=5Fallocate though > shm=5Ftoc=5Fallocate does that too. =C2=A0=C2=A0shm=5Ftoc=5Finsert does that too, and=C2=A0=C2=A0we can repor= t error earlier. Regards, Zhang Mingli --63bfadaa_b03e0c6_17004 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
Hi,

On Jan 12, 2023, 14:34 +0800, Zhang Mingli <zmlpostgres=40gmail.com>= ;, wrote:
Hi, hackers

Some conditions in shm=5Ftoc=5Finsert and shm=5Ftoc=5Fallocate are bogus,= like:
if (toc=5Fbytes + nbytes > total=5Fbytes =7C=7C toc=5Fbytes + = nbytes < toc=5Fbytes)
Remove the condition =60toc=5Fbytes + nbytes < toc=5Fbytes=60 and take= a sizeof(shm=5Fentry) into account in shm=5Ftoc=5Fallocate though&=23160= ;
shm=5Ftoc=5Fallocate does that too.
&=23160;&=23160;shm=5Ftoc=5Finsert does that too, a= nd&=23160;&=23160;we can report error earlier.

Regards,
Zhang Mingli
--63bfadaa_b03e0c6_17004--