Bug #34926 false stack corruption warnings maria_open
Submitted: 28 Feb 2008 14:03 Modified: 28 Apr 2008 22:56
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S2 (Serious)
Version:mysql-5.1.23a-maria-alpha-winx64 (debug) OS:Microsoft Windows (XP 64-bit)
Assigned to: Kent Boortz CPU Architecture:Any
Triage: D2 (Serious)

[28 Feb 2008 14:03] Shane Bester
Description:
The official debug build of mysql-5.1.23a-maria-alpha-winx64 prints these messages to error log which indicates a buffer overflow or memory corruption:

Run-Time Check Failure #2 - Stack around the variable 'rec_per_key_part' was corrupted.
Run-Time Check Failure #2 - Stack around the variable 'share' was corrupted. 
Run-Time Check Failure #2 - Stack around the variable 'share_buff' was corrupted.
Run-Time Check Failure #2 - Stack around the variable 'info' was corrupted. 
Run-Time Check Failure #2 - Stack around the variable 'name_buff' was corrupted.

How to repeat:
mysqld-debug.exe --skip-grant-tables --skip-name-resolve --console --log-bin

mysql -uroot test
create table t1(id int)engine=maria;
insert into t1 values (1);

Suggested fix:
Find and fix the memory corruption. I'll build from source and try identify where this is happening.
[28 Feb 2008 16:41] Shane Bester
verified on 64-bit windows debug build 5.1.24-maria-alpha-debug-log from todays BK.
[28 Feb 2008 16:46] Shane Bester
there's a bug in maria_open() causing these buffer overflows. still looking..
[28 Feb 2008 18:04] Shane Bester
doesn't happen when the same source is built as 32-bit binary. so, this appears 64-bit specific.
[28 Feb 2008 23:40] Vladislav Vaintroub
Here is my output of the official maria debug binary:

Version: '5.1.23a-maria-alpha-community-maria-debug-log'  socket: ''  port: 3306
  MySQL Community Server - Debug [Maria] (GPL)
Error:Run-Time Check Failure #3 - The variable 'MYSQLlval' is being used without
 being defined. At :0
Error:Run-Time Check Failure #2 - Stack around the variable '_db_stack_frame_' w
as corrupted. At :0
Error:Run-Time Check Failure #2 - Stack around the variable 'rec_per_key_part' w
as corrupted. At :0
Error:Run-Time Check Failure #2 - Stack around the variable 'share' was corrupte
d. At :0
Error:Run-Time Check Failure #2 - Stack around the variable 'share_buff' was cor
rupted. At :0
Error:Run-Time Check Failure #2 - Stack around the variable 'info' was corrupted
. At :0
Error:Run-Time Check Failure #2 - Stack around the variable 'name_buff' was corr
upted. At :0

in addition to Shane's reported warning there is also 

Error:Run-Time Check Failure #3 - The variable 'MYSQLlval' is being used without.

This warning is correct, and stems from using outdated bison during the 
build.There is also Bug#31228 about this. The solution would be to use bison 2.1 (or maybe newer, 2.1 works good for me)

Other warnings seem about stack corruption seem to be wrong, I checked stack around name_buff and found  the usual *uninitialized* pattern (0xcc bytes)
However , when using VS2005 Service Pack 1 I was not able to reproduce the issue anymore.

Searched for similar problems on Microsoft connect, found wrongly reported stack corruption on x64 , fixed in SP1
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=113800

So the correct fix for the problem seems to be
1)Build the release binaries with VS2005 SP1
to fix "stack corrupted" warning.

Please note , that SP1 is currently the *only* supported version of VS2005 (for Microsoft, release of a service pack automatically invalidates RTM and earlier service packs)

2)Build with bison 2.1, or later if it works, to fix "uninitialized variable"
warning
[29 Feb 2008 15:33] Shane Bester
Changing category to Server: Compiling.
Bison needs updating and the latest SP needs to be installed for VS.NET.
[28 Apr 2008 19:36] Kent Boortz
Bison 2.3 will be used when building 5.0.60, 5.1.25 and 6.0.6.
[28 Apr 2008 22:56] Paul Dubois
Noted in 5.0.60, 5.1.25, 6.0.6 changelogs.

Some binaries produced stack corruption messages due to being built
with versions of bison older than 2.1. Builds are now created using
bison 2.3.
[28 Apr 2008 22:56] Paul Dubois
Noted in 5.0.60, 5.1.25, 6.0.6 changelogs.

Some binaries produced stack corruption messages due to being built
with versions of bison older than 2.1. Builds are now created using
bison 2.3.