Re: Is element access after HASH_REMOVE ever OK? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Is element access after HASH_REMOVE ever OK?
Date
Msg-id 805065.1620691570@sss.pgh.pa.us
Whole thread Raw
In response to Is element access after HASH_REMOVE ever OK?  (Thomas Munro <thomas.munro@gmail.com>)
Responses Re: Is element access after HASH_REMOVE ever OK?
List pgsql-hackers
Thomas Munro <thomas.munro@gmail.com> writes:
> However, I noticed in passing that RemoveLocalLock() accesses
> *locallock after removing it from the hash table (in assertion builds
> only).  So one question I have is whether it's actually a programming
> rule that you can't do that (at most you can compare the pointer
> against NULL), or whether it's supposed to be
> safe-if-you-know-what-you're-doing, as the existing comments hints.

I'd say it's, at best, unwarranted familiarity with the dynahash
implementation ...

> Here also is a patch that does wipe_mem on removed elements, as
> threatened last time this topic came up[1], which reveals the problem.

... one good reason being that it'll fail under this sort of
entirely-reasonable debugging aid.  Can we get rid of the unsafe
access easily?

            regards, tom lane



pgsql-hackers by date:

Previous
From: Thomas Munro
Date:
Subject: Is element access after HASH_REMOVE ever OK?
Next
From: Tom Lane
Date:
Subject: Re: Is element access after HASH_REMOVE ever OK?