Bug #93796 5.6 ASan: intermittent thread stack overrun on some MTR testcases
Submitted: 3 Jan 2019 9:42 Modified: 16 Jan 2019 14:51
Reporter: Laurynas Biveinis (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Tests Severity:S7 (Test Cases)
Version:5.6 OS:Any
Assigned to: CPU Architecture:Any

[3 Jan 2019 9:42] Laurynas Biveinis
Description:
On 5.6 with ASan enabled, main.signal_demo3 and sys_vars.max_sp_recursion_depth_func fail intermittently with:

main.signal_demo3                        w2 [ fail ]
        Test ended at 2019-01-02 14:20:35

CURRENT_TEST: main.signal_demo3
mysqltest: At line 107: query 'call proc_1()' failed with wrong errno 1436: 'Thread stack overrun:  138416 bytes used of a 262144 byte stack, and 128000 bytes needed.  Use 'mysqld --thread_stack=#' to specify a bigger stack.', instead of 1644...

sys_vars.max_sp_recursion_depth_func     w2 [ fail ]
        Test ended at 2019-01-02 14:20:41

CURRENT_TEST: sys_vars.max_sp_recursion_depth_func
mysqltest: At line 64: query 'CALL sp_addRecords(0,8)' failed: 1436: Thread stack overrun:  138416 bytes used of a 262144 byte stack, and 128000 bytes needed.  Use 'mysqld --thread_stack=#' to specify a bigger stack.

This is likely to be plaftorm- and compiler version-dependent. We saw this on CentOS 6 with devtoolset-2, x86_64 and x86, and Ubuntu Trusty.

How to repeat:
-DWITH_ASAN=ON and see above

Suggested fix:
This appears to be fixed in 5.7+ by the commit below, which can be backported to 5.6.

commit 83a9e3621595cb52e48ccb6b4a710e11e83af7d5
Author: mayank prasad <mayank.prasad@oracle.com>
Date:   Fri Aug 2 10:57:07 2013 +0530

    fixing Windows specific thread stack overrun issue seen on trunk-stage

diff --git a/mysql-test/suite/sys_vars/t/max_sp_recursion_depth_func-master.opt b/mysql-test/suite/sys_vars/t/max_sp_recursion_depth_func-master.opt
index d03d176150d..95eb3b1912f 100644
--- a/mysql-test/suite/sys_vars/t/max_sp_recursion_depth_func-master.opt
+++ b/mysql-test/suite/sys_vars/t/max_sp_recursion_depth_func-master.opt
@@ -1 +1 @@
-${?PB_HOST_SPECIFIC_MYSQLD_ARGS}
+${?PB_HOST_SPECIFIC_MYSQLD_ARGS} --thread_stack=655360
diff --git a/mysql-test/t/signal_demo3-master.opt b/mysql-test/t/signal_demo3-master.opt
index d03d176150d..95eb3b1912f 100644
--- a/mysql-test/t/signal_demo3-master.opt
+++ b/mysql-test/t/signal_demo3-master.opt
@@ -1 +1 @@
-${?PB_HOST_SPECIFIC_MYSQLD_ARGS}
+${?PB_HOST_SPECIFIC_MYSQLD_ARGS} --thread_stack=655360
[3 Jan 2019 13:46] Laurynas Biveinis
Likewise

rpl.rpl_row_sp011 'row'                  w3 [ fail ]
        Test ended at 2019-01-02 14:16:18

CURRENT_TEST: rpl.rpl_row_sp011
mysqltest: At line 76: query 'CALL test.p1()' failed: 1436: Thread stack overrun:  76976 bytes used of a 196608 byte stack, and 128000 bytes needed.  Use 'mysqld --thread_stack=#' to specify a bigger stack.

which is likewise fixed by

commit 71d72830c2c6b487058eab9b2823d6313a133745
Author: parveez <parveez.baig@oracle.com>
Date:   Wed Sep 16 14:58:00 2015 +0200

    Bug #21161874 -TEST:RPL.RPL_ROW_SP011 FAILS WITH THREAD STACK OVERRRUN. rpl_row_sp011 test was failing due to thread stack overrun problem.Fix: increased the thread stack size for the test in the opt file.

diff --git a/mysql-test/suite/rpl/t/rpl_row_sp011-master.opt b/mysql-test/suite/rpl/t/rpl_row_sp011-master.opt
index d03d176150d..2a213c3b06f 100644
--- a/mysql-test/suite/rpl/t/rpl_row_sp011-master.opt
+++ b/mysql-test/suite/rpl/t/rpl_row_sp011-master.opt
@@ -1 +1,2 @@
 ${?PB_HOST_SPECIFIC_MYSQLD_ARGS}
+--thread_stack=409600
diff --git a/mysql-test/suite/rpl/t/rpl_row_sp011.test b/mysql-test/suite/rpl/t/rpl_row_sp011.test
index c5027c79f7b..a7a5209efbf 100644
--- a/mysql-test/suite/rpl/t/rpl_row_sp011.test
+++ b/mysql-test/suite/rpl/t/rpl_row_sp011.test
@@ -2,8 +2,11 @@
 # Original Author: JBM                                                      #
 # Original Date: Aug/18/2005                                                #
 # Updated: 08/29/2005  turned on diff and commented out debug SQL statements#
+# Updated: sep/16/2015                                                      #
+#          This testcase requires minimum stack size of 300KB to run on WIN.#
+#          Modified *-master.opt file to increase the thread_stack to 400KB.#
 #############################################################################
-#TEST: SP to test alter table and nested SP calls                           #
+# TEST: SP to test alter table and nested SP calls                          #
 #############################################################################
 
 # Includes
[16 Jan 2019 14:51] MySQL Verification Team
Hi,

Thank you for your bug report.

I have got similar results with XCode on my iMac by using the option  for the stack logging and memory graph debugger.

Hence, I verify this bug and will ask for the backport of the patches from 5.7 to 5.6.

Thank you.