]> granicus.if.org Git - postgresql/commit
Fix segment_bins corruption in dsa.c.
authorThomas Munro <tmunro@postgresql.org>
Thu, 20 Sep 2018 03:52:39 +0000 (15:52 +1200)
committerThomas Munro <tmunro@postgresql.org>
Thu, 20 Sep 2018 04:03:51 +0000 (16:03 +1200)
commitba20d392584cdecc2808fe936448d127f43f2c07
tree4f1c039db7194b154dddf05f2c04a60a73a6a792
parent98a4e814e473784716f889d8e67d66c38e94c6b0
Fix segment_bins corruption in dsa.c.

If a segment has been freed by dsa.c because it is entirely empty, other
backends must make sure to unmap it before following links to new
segments that might happen to have the same index number, or they could
finish up looking at a defunct segment and then corrupt the segment_bins
lists.  The correct protocol requires checking freed_segment_counter
after acquiring the area lock and before resolving any index number to a
segment.  Add the missing checks and an assertion.

Back-patch to 10, where dsa.c first arrived.

Author: Thomas Munro
Reported-by: Tomas Vondra
Discussion: https://postgr.es/m/CAEepm%3D0thg%2Bja5zGVa7jBy-uqyHrTqTm8HGhEOtMmigGrAqTbw%40mail.gmail.com
src/backend/utils/mmgr/dsa.c