Skip to content

Comments

fix check_stack_depth call#82

Open
ivan-v-kush wants to merge 2 commits intopowa-team:masterfrom
ivan-v-kush:fix-CHECK_STACK_DEPTH
Open

fix check_stack_depth call#82
ivan-v-kush wants to merge 2 commits intopowa-team:masterfrom
ivan-v-kush:fix-CHECK_STACK_DEPTH

Conversation

@ivan-v-kush
Copy link

@ivan-v-kush ivan-v-kush commented Jan 28, 2026

Hello!

check_stack_depth prevents infinite loops in recursions, not CHECK_FOR_INTERRUPTS

https://github.com/postgres/postgres/blob/master/src/backend/utils/misc/stack_depth.c#L84

@ivan-v-kush ivan-v-kush changed the title fix CHECK_STACK_DEPTH call fix check_stack_depth call Jan 28, 2026
@rjuju rjuju self-assigned this Jan 31, 2026
* any problem.
*/
CHECK_FOR_INTERRUPTS();
check_stack_depth();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the comment is probably poorly worded. The idea here wasn't to automatically raise an error in case of a too deep recursion but being able to cancel the query if this ends up recursing too much and/or infinitely.

We don't have a infinite recursion problem (at least there wasn't any such report and the this code hasn't change in years) so I would be more worried about not being able to cancel a query that has a lot of complex expressions.

Now if there were an infinite recursion then it would likely end up crashing, and crashing fast, so I'm not opposed to adding a stack depth check, but on top of the CFI, not instead of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants