Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 46ef520

Browse files
Mark buffers as defined to Valgrind consistently.
Make PinBuffer() mark buffers as defined to Valgrind unconditionally, including when the buffer header spinlock must be acquired. Failure to handle that case could lead to false positive reports from Valgrind. This theoretically creates a risk that we'll mark buffers defined even when external callers don't end up with a buffer pin. That seems perfectly acceptable, though, since in general we make no guarantees about buffers that are unsafe to access being reliably marked as unsafe. Oversight in commit 1e0dfd1, which added valgrind buffer access instrumentation.
1 parent 72eab84 commit 46ef520

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/backend/storage/buffer/bufmgr.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,11 +1636,13 @@ PinBuffer(BufferDesc *buf, BufferAccessStrategy strategy)
16361636
result = (buf_state & BM_VALID) != 0;
16371637

16381638
/*
1639-
* If we successfully acquired our first pin on this buffer
1640-
* within this backend, mark buffer contents defined
1639+
* Assume that we acquired a buffer pin for the purposes of
1640+
* Valgrind buffer client checks (even in !result case) to
1641+
* keep things simple. Buffers that are unsafe to access are
1642+
* not generally guaranteed to be marked undefined in any
1643+
* case.
16411644
*/
1642-
if (result)
1643-
VALGRIND_MAKE_MEM_DEFINED(BufHdrGetBlock(buf), BLCKSZ);
1645+
VALGRIND_MAKE_MEM_DEFINED(BufHdrGetBlock(buf), BLCKSZ);
16441646
break;
16451647
}
16461648
}

0 commit comments

Comments
 (0)