Re: Stack overflow issue
Heikki Linnakangas <hlinnaka@iki.fi>
From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Egor Chindyaskin <kyzevan23@mail.ru>, Sascha Kuhl
<yogidabanli@gmail.com>, pgsql-hackers@lists.postgresql.org
Date: 2024-01-10T21:25:42Z
Lists: pgsql-hackers
On 05/01/2024 19:23, Robert Haas wrote: > On Fri, Nov 24, 2023 at 10:47 AM Heikki Linnakangas <hlinnaka@iki.fi> wrote: >> What do you think? > > At least for 0001 and 0002, I think we should just add the stack depth checks. > > With regard to 0001, CommitTransactionCommand() and friends are hard > enough to understand as it is; they need "goto" like I need an extra > hole in my head. > > With regard to 0002, this function isn't sufficiently important to > justify adding special-case code for an extremely rare event. We > should just handle it the way we do in general. > > I agree that in the memory-context case it might be worth expending > some more code to be more clever. But I probably wouldn't do that for > MemoryContextStats(); check_stack_depth() seems fine for that one. > > In general, I think we should try to keep the number of places that > handle stack overflow in "special" ways as small as possible. The problem with CommitTransactionCommand (or rather AbortCurrentTransaction() which has the same problem) and ShowTransactionStateRec is that they get called in a state where aborting can lead to a panic. If you add a "check_stack_depth()" to them and try to reproducer scripts that Egor posted, you still get a panic. I'm not sure if MemoryContextStats() could safely elog(ERROR). But at least it would mask the "out of memory" that caused the stats to be printed in the first place. -- Heikki Linnakangas Neon (https://neon.tech)
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