some question about _bt_getbuf

zoulx1982 <zoulx1982@163.com>

From: 自己 <zoulx1982@163.com>
To: "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2018-05-14T14:27:02Z
Lists: pgsql-hackers
Hi,
i run test using pg10.0 on my machine, and the program crashed on _bt_getbuf.
And i found the following code:
the routine _bt_page_recyclable say maybe the page is all-zero page, if so
then the code run (BTPageOpaque) PageGetSpecialPointer(page); it will be failed because
it access invalid memory.
I don't know whether it is so. Look forward t your reply, thanks.


                                if (_bt_page_recyclable(page))
{
/*
* If we are generating WAL for Hot Standby then create a
* WAL record that will allow us to conflict with queries
* running on standby.
*/
if (XLogStandbyInfoActive() && RelationNeedsWAL(rel))
{
                                                BTPageOpaque opaque = (BTPageOpaque) PageGetSpecialPointer(page);  /* if page is all-zero, this will failed */
_bt_log_reuse_page(rel, blkno, opaque->btpo.xact);
}


/* Okay to use page.  Re-initialize and return it */
_bt_pageinit(page, BufferGetPageSize(buf));
return buf;
}

Commits

  1. Avoid emitting a bogus WAL record when recycling an all-zero btree page.