Skip to content

Commit

Permalink
[#15159] test: avoid ASAN stack overflow
Browse files Browse the repository at this point in the history
Summary:
The yb_pg_errors regress test covered by Java test TestPgRegressPgMisc runs a
query to test infinite recursion.  It is supposed to catch it, but before that,
ASAN catches it and throws fatal error.  This was not the case with clang13,
but it is the case with clang15.  Temporarily reduce max_stack_depth at that
time so that postgres catches the issue before ASAN.

Close: #15159

Test Plan:
Jenkins: test regex: .*TestPgRegressPgMisc.*

./yb_build.sh asan --clang15 --java-test TestPgRegressPgMisc

Reviewers: myang

Reviewed By: myang

Subscribers: yql

Differential Revision: https://phabricator.dev.yugabyte.com/D22716
  • Loading branch information
jaki committed Feb 2, 2023
1 parent b10f16a commit 8c26092
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/postgres/src/test/regress/expected/yb_pg_errors.out
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,19 @@ NULL);
ERROR: syntax error at or near "NUL"
LINE 16: ...L, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, id4 I...
^
-- YB: With default max_stack_depth, ASAN build detects stack-overflow first.
-- Prevent that by lowering max_stack_depth temporarily.
set max_stack_depth = '900kB';
-- Check that stack depth detection mechanism works and
-- max_stack_depth is not set too high
create function infinite_recurse() returns int as
'select infinite_recurse()' language sql;
\set VERBOSITY terse
select infinite_recurse();
ERROR: stack depth limit exceeded
-- YB: undo above change. Some experimentation showed issues with some later
-- statements otherwise.
reset max_stack_depth;
-- YB note: check for unsupported system columns.
CREATE TABLE test_tab1(id INT);
INSERT INTO test_tab1 VALUES (1) RETURNING ctid;
Expand Down
8 changes: 8 additions & 0 deletions src/postgres/src/test/regress/sql/yb_pg_errors.sql
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,21 @@ UNIQUE
NOT
NULL);

-- YB: With default max_stack_depth, ASAN build detects stack-overflow first.
-- Prevent that by lowering max_stack_depth temporarily.
set max_stack_depth = '900kB';

-- Check that stack depth detection mechanism works and
-- max_stack_depth is not set too high
create function infinite_recurse() returns int as
'select infinite_recurse()' language sql;
\set VERBOSITY terse
select infinite_recurse();

-- YB: undo above change. Some experimentation showed issues with some later
-- statements otherwise.
reset max_stack_depth;

-- YB note: check for unsupported system columns.
CREATE TABLE test_tab1(id INT);
INSERT INTO test_tab1 VALUES (1) RETURNING ctid;
Expand Down

0 comments on commit 8c26092

Please sign in to comment.