|
49 | 49 | #include "storage/proc.h"
|
50 | 50 | #include "storage/smgr.h"
|
51 | 51 | #include "storage/standby.h"
|
| 52 | +#include "utils/memdebug.h" |
52 | 53 | #include "utils/ps_status.h"
|
53 | 54 | #include "utils/rel.h"
|
54 | 55 | #include "utils/resowner_private.h"
|
@@ -1633,6 +1634,13 @@ PinBuffer(BufferDesc *buf, BufferAccessStrategy strategy)
|
1633 | 1634 | buf_state))
|
1634 | 1635 | {
|
1635 | 1636 | result = (buf_state & BM_VALID) != 0;
|
| 1637 | + |
| 1638 | + /* |
| 1639 | + * If we successfully acquired our first pin on this buffer |
| 1640 | + * within this backend, mark buffer contents defined |
| 1641 | + */ |
| 1642 | + if (result) |
| 1643 | + VALGRIND_MAKE_MEM_DEFINED(BufHdrGetBlock(buf), BLCKSZ); |
1636 | 1644 | break;
|
1637 | 1645 | }
|
1638 | 1646 | }
|
@@ -1683,6 +1691,13 @@ PinBuffer_Locked(BufferDesc *buf)
|
1683 | 1691 | */
|
1684 | 1692 | Assert(GetPrivateRefCountEntry(BufferDescriptorGetBuffer(buf), false) == NULL);
|
1685 | 1693 |
|
| 1694 | + /* |
| 1695 | + * Buffer can't have a preexisting pin, so mark its page as defined to |
| 1696 | + * Valgrind (this is similar to the PinBuffer() case where the backend |
| 1697 | + * doesn't already have a buffer pin) |
| 1698 | + */ |
| 1699 | + VALGRIND_MAKE_MEM_DEFINED(BufHdrGetBlock(buf), BLCKSZ); |
| 1700 | + |
1686 | 1701 | /*
|
1687 | 1702 | * Since we hold the buffer spinlock, we can update the buffer state and
|
1688 | 1703 | * release the lock in one operation.
|
@@ -1728,6 +1743,9 @@ UnpinBuffer(BufferDesc *buf, bool fixOwner)
|
1728 | 1743 | uint32 buf_state;
|
1729 | 1744 | uint32 old_buf_state;
|
1730 | 1745 |
|
| 1746 | + /* Mark undefined, now that no pins remain in backend */ |
| 1747 | + VALGRIND_MAKE_MEM_NOACCESS(BufHdrGetBlock(buf), BLCKSZ); |
| 1748 | + |
1731 | 1749 | /* I'd better not still hold any locks on the buffer */
|
1732 | 1750 | Assert(!LWLockHeldByMe(BufferDescriptorGetContentLock(buf)));
|
1733 | 1751 | Assert(!LWLockHeldByMe(BufferDescriptorGetIOLock(buf)));
|
|
0 commit comments