Re: Stack overflow issue
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alexander Korotkov <aekorotkov@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>, Heikki Linnakangas <hlinnaka@iki.fi>,
Egor Chindyaskin <kyzevan23@mail.ru>,
Sascha Kuhl <yogidabanli@gmail.com>,
pgsql-hackers@lists.postgresql.org
Date: 2024-03-06T22:52:27Z
Lists: pgsql-hackers
Attachments
- v5-0003-Avoid-recursion-in-MemoryContext-functions.patch (text/x-diff) patch v5-0003
Alexander Korotkov <aekorotkov@gmail.com> writes: > The revised set of remaining patches is attached. > ... > 0003 Avoid recursion in MemoryContext functions > I've renamed MemoryContextTraverse() => MemoryContextTraverseNext(), > which I think is a bit more intuitive. Also I fixed > MemoryContextMemConsumed(), which was still trying to use the removed > argument "print" of MemoryContextStatsInternal() function. This patch still doesn't compile for me --- MemoryContextMemConsumed got modified some more by commit 743112a2e, and needs minor fixes. I initially didn't like the definition of MemoryContextTraverseNext because it requires two copies of the "process node" logic. However, that seems fine for most of the callers, and even where we are duplicating logic it's just a line or so, so I guess it's ok. However, MemoryContextTraverseNext seems undercommented to me, plus the claim that it traverses in depth-first order is just wrong. I found some bugs in MemoryContextStatsInternal too: the old logic assumed that ichild exceeding max_children was the only way to get into the summarization logic, but now ichild minus max_children could very well be negative. Fortunately we can just reset ichild to zero and not worry about having any connection between the first loop and the second. Here's a v5 of 0003 with those issues and some more-cosmetic ones cleaned up. I didn't look at 0001 or 0002. regards, tom lane
Commits
-
Refactoring for CommitTransactionCommand()/AbortCurrentTransaction()
- 40126ac68f2f 17.0 landed
-
Avoid recursion in MemoryContext functions
- 4c1973fcaecd 17.0 landed
-
Avoid stack overflow in ShowTransactionStateRec()
- 6f38c43eb135 17.0 landed
-
Turn tail recursion into iteration in CommitTransactionCommand()
- fefd9a3fed27 17.0 landed
-
Adjust memory allocation functions to allow sibling calls
- 743112a2e993 17.0 cited
-
Add missing check_stack_depth() to some recursive functions
- d57b7cc3338e 17.0 landed
-
In the Snowball dictionary, don't try to stem excessively-long words.
- f5aa855cd8a6 11.18 landed
- f204ad3a2b19 13.9 landed
- e969f1ae2b01 14.6 landed
- cba393a10af8 10.23 landed
- a53e0ea782c5 12.13 landed
- 61f6e5c23603 15.0 landed
- 1058555a5ecc 16.0 landed
-
Defend against stack overrun in a few more places.
- f25bed3801e1 16.0 landed
- 3d3c05c70fc7 15.0 landed
- f5157a9acc9d 10.23 landed
- 599a487b093a 12.13 landed
- 444ec169a7de 14.6 landed
- 310d734efb3b 11.18 landed
- 2d1f1523ce83 13.9 landed