Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#15682] YSQL: Fix stack_is_too_deep function in ASAN
Summary: The `stack_is_too_deep` Postgres function is used to limits stack depth based on total stack size. The stack size is calculated by using local variables address offset. This method works well in case of regular call stack (i.e. when all stack frames are allocated in stack). But for the `detect_stack_use_after_return` ASAN uses fake stack. In case of using it stack frames are allocated in the heap. As a result it is not possible to estimate stack depth base on local variables address offset and the `stack_is_too_deep` returns almost unpredictable results. To make `stack_is_too_deep `return predictable result in case of ASAN it is reasonable to return `false` all the time. **Note**: YSQL has some unit tests which checks that Postgres can detect too deep recursion. These tests changes the `max_stack_depth` GUC variable to lower value. And later restore the original value with the `RESET max_stack_depth` statement. To make these tests works under the ASAN the function returns true in case the `max_stack_depth` GUC contains non default value and number of call stack frames is huge enough. The check of call stack frames is required to avoid undesired failure on attempt to restore original value for the `max_stack_depth` GUC with the `RESET max_stack_depth` statement. Jira: DB-5047 Test Plan: Jenkins ``` ./yb_build.sh asan --java-test org.yb.pgsql.TestPgRegressJson#testPgRegressJson ``` Reviewers: loginov, jason Reviewed By: loginov, jason Subscribers: yql Tags: #jenkins-ready Differential Revision: https://phorge.dev.yugabyte.com/D35979
- Loading branch information