MCPcopy Create free account
hub / github.com/apache/cloudberry / stack_is_too_deep

Function stack_is_too_deep

src/backend/tcop/postgres.c:4475–4521  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4473}
4474
4475bool
4476stack_is_too_deep(void)
4477{
4478 char stack_top_loc;
4479 long stack_depth;
4480
4481 /*
4482 * Compute distance from reference point to my local variables
4483 */
4484 stack_depth = (long) (stack_base_ptr - &stack_top_loc);
4485
4486 /*
4487 * Take abs value, since stacks grow up on some machines, down on others
4488 */
4489 if (stack_depth < 0)
4490 stack_depth = -stack_depth;
4491
4492 /*
4493 * Trouble?
4494 *
4495 * The test on stack_base_ptr prevents us from erroring out if called
4496 * during process setup or in a non-backend process. Logically it should
4497 * be done first, but putting it here avoids wasting cycles during normal
4498 * cases.
4499 */
4500 if (stack_depth > max_stack_depth_bytes &&
4501 stack_base_ptr != NULL)
4502 return true;
4503
4504 /*
4505 * On IA64 there is a separate "register" stack that requires its own
4506 * independent check. For this, we have to measure the change in the
4507 * "BSP" pointer from PostgresMain to here. Logic is just as above,
4508 * except that we know IA64's register stack grows up.
4509 *
4510 * Note we assume that the same max_stack_depth applies to both stacks.
4511 */
4512#if defined(__ia64__) || defined(__ia64)
4513 stack_depth = (long) (ia64_get_bsp() - register_stack_base_ptr);
4514
4515 if (stack_depth > max_stack_depth_bytes &&
4516 register_stack_base_ptr != NULL)
4517 return true;
4518#endif /* IA64 */
4519
4520 return false;
4521}
4522
4523/* GUC check hook for max_stack_depth */
4524bool

Callers 2

check_stack_depthFunction · 0.85
rstacktoodeepFunction · 0.85

Calls 1

ia64_get_bspFunction · 0.85

Tested by

no test coverage detected