Skip to content

Commit

Permalink
Fix race condition when sharing tuple descriptors.
Browse files Browse the repository at this point in the history
Parallel query processes that called BlessTupleDesc() for identical
tuple descriptors at the same moment could crash.  There was code to
handle that rare case, but it dereferenced a bogus DSA pointer.  Repair.

Back-patch to 11, where commit cc5f8136 added support for sharing tuple
descriptors in parallel queries.

Reported-by: Eric Thinnes <e.thinnes@gmx.de>
Discussion: https://postgr.es/m/99aaa2eb-e194-bf07-c29a-1a76b4f2bcf9%40gmx.de
  • Loading branch information
macdice committed May 29, 2021
1 parent d69fcb9 commit b1d6538
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/backend/utils/cache/typcache.c
Expand Up @@ -2822,7 +2822,7 @@ find_or_make_matching_shared_tupledesc(TupleDesc tupdesc)
Assert(record_table_entry->key.shared);
result = (TupleDesc)
dsa_get_address(CurrentSession->area,
record_table_entry->key.shared);
record_table_entry->key.u.shared_tupdesc);
Assert(result->tdrefcount == -1);

return result;
Expand Down

0 comments on commit b1d6538

Please sign in to comment.