Re: [HACKERS] Shortcoming in CLOBBER_FREED_MEMORY coverage: disk buffer pointers

2015-01-27 Thread Jim Nasby
On 1/27/15 5:16 PM, Tom Lane wrote: Jim Nasby writes: On 1/26/15 6:11 PM, Greg Stark wrote: Fwiw I think our experience is that bugs where buffers are unpinned get exposed pretty quickly in production. I suppose the same might not be true for rarely called codepaths or in cases where the buf

Re: [HACKERS] Shortcoming in CLOBBER_FREED_MEMORY coverage: disk buffer pointers

2015-01-27 Thread Tom Lane
Jim Nasby writes: > On 1/26/15 6:11 PM, Greg Stark wrote: >> Fwiw I think our experience is that bugs where buffers are unpinned get >> exposed pretty quickly in production. I suppose the same might not be true >> for rarely called codepaths or in cases where the buffers are usually >> already

Re: [HACKERS] Shortcoming in CLOBBER_FREED_MEMORY coverage: disk buffer pointers

2015-01-27 Thread Jim Nasby
On 1/26/15 6:11 PM, Greg Stark wrote: On Tue, Jan 27, 2015 at 12:03 AM, Jim Nasby mailto:jim.na...@bluetreble.com>> wrote: But one backend can effectively "pin" a buffer more than once, no? If so, then ISTM there's some risk that code path A pins and forgets to unpin, but path B accidenta

Re: [HACKERS] Shortcoming in CLOBBER_FREED_MEMORY coverage: disk buffer pointers

2015-01-26 Thread Greg Stark
On Tue, Jan 27, 2015 at 12:03 AM, Jim Nasby wrote: > But one backend can effectively "pin" a buffer more than once, no? If so, > then ISTM there's some risk that code path A pins and forgets to unpin, but > path B accidentally unpins for A. > The danger is that there's a codepath that refers to

Re: [HACKERS] Shortcoming in CLOBBER_FREED_MEMORY coverage: disk buffer pointers

2015-01-26 Thread Jim Nasby
On 1/26/15 4:51 PM, Tom Lane wrote: Jim Nasby writes: On 1/24/15 3:31 PM, Tom Lane wrote: Another idea is to teach Valgrind that whenever a backend reduces its pin count on a shared buffer to zero, that buffer should become undefined memory. Shouldn't this technically tie in with Resour

Re: [HACKERS] Shortcoming in CLOBBER_FREED_MEMORY coverage: disk buffer pointers

2015-01-26 Thread Tom Lane
Jim Nasby writes: > On 1/24/15 3:31 PM, Tom Lane wrote: >> Another idea is to teach Valgrind that whenever a backend reduces its >> pin count on a shared buffer to zero, that buffer should become undefined >> memory. > > Shouldn't this technically tie in with ResourceOwners? No. ResourceOwner

Re: [HACKERS] Shortcoming in CLOBBER_FREED_MEMORY coverage: disk buffer pointers

2015-01-26 Thread Jim Nasby
On 1/24/15 3:31 PM, Tom Lane wrote: Another idea is to teach Valgrind that whenever a backend reduces its pin count on a shared buffer to zero, that buffer should become undefined memory. Shouldn't this technically tie in with ResourceOwners? If a pointer takes the pin count from 1 to 2, the

Re: [HACKERS] Shortcoming in CLOBBER_FREED_MEMORY coverage: disk buffer pointers

2015-01-24 Thread Tom Lane
Peter Geoghegan writes: > On Sat, Jan 24, 2015 at 1:31 PM, Tom Lane wrote: >> Another idea is to teach Valgrind that whenever a backend reduces its >> pin count on a shared buffer to zero, that buffer should become undefined >> memory. > That should be fairly straightforward to implement. >> Bu

Re: [HACKERS] Shortcoming in CLOBBER_FREED_MEMORY coverage: disk buffer pointers

2015-01-24 Thread Peter Geoghegan
On Sat, Jan 24, 2015 at 1:31 PM, Tom Lane wrote: > Another idea is to teach Valgrind that whenever a backend reduces its > pin count on a shared buffer to zero, that buffer should become undefined > memory. That should be fairly straightforward to implement. > But I don't know if that will help

[HACKERS] Shortcoming in CLOBBER_FREED_MEMORY coverage: disk buffer pointers

2015-01-24 Thread Tom Lane
While the CLOBBER_FREED_MEMORY hack does a fairly good job of catching stale pointers to already-freed memory, commit fd496129d160950e exhibits a case that is not caught at all: RelationBuildRowSecurity was copying *pointers into disk buffers* into backend-local relcaches. This would of course wor