From: Robert Haas Date: Fri, 27 Jul 2012 18:19:47 +0000 (+0000) Subject: Fix another bug related to marked CHashPtrs. X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=6c84f78a919097ebaf89d1cf5fab46acbf99ce7b;p=users%2Fandresfreund%2Fpostgres.git Fix another bug related to marked CHashPtrs. --- diff --git a/src/backend/utils/hash/chash.c b/src/backend/utils/hash/chash.c index 4855bc8ace..700a2e9327 100644 --- a/src/backend/utils/hash/chash.c +++ b/src/backend/utils/hash/chash.c @@ -463,6 +463,7 @@ retry: * in the table. Even for a quite modestly size table this is likely * to exceed the number of CPU cores. */ + Assert(!CHashPtrIsMarked(scan.target)); nnew->next = scan.target; if (!__sync_bool_compare_and_swap(scan.pointer_to_target, scan.target, new)) @@ -557,6 +558,9 @@ CHashDelete(CHashTable table, void *entry) * case, res->pointer_to_target will a pointer to the address where the value * of target was found. res->target_node will be a pointer to the address of * the CHashNode with offset res->target, unless res->target is invalid. + * + * NB: If you change this function, make sure to adjust CHashBucketCleanup + * similarly. */ static void CHashBucketScan(CHashTable table, @@ -622,7 +626,7 @@ zap: */ CHashAddToGarbage(table, hashcode & table->bucket_mask, target); - target = next; + target = CHashPtrUnmark(next); continue; } else @@ -948,7 +952,7 @@ retry: /* We removed the item. */ CHashAddToGarbage(table, hashcode & table->bucket_mask, target); - target = next; + target = CHashPtrUnmark(next); continue; } else