Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZBwDL-0008Ao-Qh for pgsql-bugs@arkaria.postgresql.org; Mon, 06 Jul 2015 02:32:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZBwDL-0007lh-7W for pgsql-bugs@arkaria.postgresql.org; Mon, 06 Jul 2015 02:32:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZBP88-0001Bf-IZ for pgsql-bugs@postgresql.org; Sat, 04 Jul 2015 15:13:24 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ZBP7v-0006iZ-M1 for pgsql-bugs@postgresql.org; Sat, 04 Jul 2015 15:13:24 +0000 MIME-Version: 1.0 Subject: BUG #13487: GetBufferFromRing code bug To: pgsql-bugs@postgresql.org From: jingwei_5107@qq.com Date: Sat, 04 Jul 2015 15:12:03 +0000 Message-ID: <20150704151203.1190.44251@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.6 (-) Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 13487 Logged by: will Email address: jingwei_5107@qq.com PostgreSQL version: 9.4.4 Operating system: It does not matter Description: In GetBufferFromRing method(/src/backend/storage/buffer/freelist.c),I think the following code: 506 buf = &BufferDescriptors[bufnum - 1]; 507 LockBufHdr(buf); 508 if (buf->refcount == 0 && buf->usage_count <= 1) 509 { 510 strategy->current_was_in_ring = true; 511 return buf; 512 } 513 UnlockBufHdr(buf); should be changed to(Adding line 510): 506 buf = &BufferDescriptors[bufnum - 1]; 507 LockBufHdr(buf); 508 if (buf->refcount == 0 && buf->usage_count <= 1) 509 { 510 UnlockBufHdr(buf);// add this line 511 strategy->current_was_in_ring = true; 512 return buf; 513 } 514 UnlockBufHdr(buf); It should Unlock the buf before returning buf, after exclusively accessing the buf's refcount&usage_count member. Am I right? Any reply is appreciated if I'm wrong. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs