forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitd303849
committed
Don't leak compiled regex(es) when an ispell cache entry is dropped.
The text search cache mechanisms assume that we can clean upan invalidated dictionary cache entry simply by resetting theassociated long-lived memory context. However, that does not workfor ispell affixes that make use of regular expressions, becausethe regex library deals in plain old malloc. Hence, we leakedcompiled regex(es) any time we dropped such a cache entry. Thatcould quickly add up, since even a fairly trivial regex can use uptens of kB, and a large one can eat megabytes. Add a memory contextcallback to ensure that a regex gets freed when its owning cacheentry is cleared.Found via valgrind testing.This problem is ancient, so back-patch to all supported branches.Discussion:https://postgr.es/m/3816764.1616104288@sss.pgh.pa.us1 parent415ffdc commitd303849
2 files changed
+41
-4
lines changedLines changed: 29 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
654 | 654 |
| |
655 | 655 |
| |
656 | 656 |
| |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
657 | 668 |
| |
658 | 669 |
| |
659 | 670 |
| |
| |||
716 | 727 |
| |
717 | 728 |
| |
718 | 729 |
| |
| 730 | + | |
719 | 731 |
| |
720 | 732 |
| |
721 | 733 |
| |
| |||
729 | 741 |
| |
730 | 742 |
| |
731 | 743 |
| |
732 |
| - | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
733 | 754 |
| |
734 | 755 |
| |
735 | 756 |
| |
736 | 757 |
| |
737 | 758 |
| |
738 | 759 |
| |
739 |
| - | |
| 760 | + | |
740 | 761 |
| |
741 | 762 |
| |
742 | 763 |
| |
743 | 764 |
| |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
744 | 770 |
| |
745 | 771 |
| |
746 | 772 |
| |
| |||
2133 | 2159 |
| |
2134 | 2160 |
| |
2135 | 2161 |
| |
2136 |
| - | |
| 2162 | + | |
2137 | 2163 |
| |
2138 | 2164 |
| |
2139 | 2165 |
| |
|
Lines changed: 12 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
81 | 81 |
| |
82 | 82 |
| |
83 | 83 |
| |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
84 | 95 |
| |
85 | 96 |
| |
86 | 97 |
| |
| |||
97 | 108 |
| |
98 | 109 |
| |
99 | 110 |
| |
100 |
| - | |
| 111 | + | |
101 | 112 |
| |
102 | 113 |
| |
103 | 114 |
| |
|
0 commit comments
Comments
(0)