Bug #27811 The variable 'join_tab' is being used without being defined

Submitted: 13 Apr 2007 14:43 Modified: 8 May 2007 1:21
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:5.0.40-debug OS:Windows
Assigned to: Georgi Kodinov CPU Architecture:Any

[13 Apr 2007 14:43] Shane Bester
Description:
Compile mysqld-debug.exe using full debug libraries on windows using visual studio 2005.

Run the testcase, and get the message which I'll type:

Debug Error!
Program: C:\build\mysql-5.0.40\sql\debug\mysqld-debug.exe
Module: C:\build\mysql-5.0.40\sql\debug\mysqld-debug.exe
File: c:\build\mysql-5.0.40\sql\sql_select.cpp
Line: 10204

Run-Time Check Failure #3 - The variable 'join_tab' is being used without being defined.

(Press Retry to debug the application)

Stack:
ntdll.dll!DbgBreakPoint
mysqld-debug.exe!failwithmessage
mysqld-debug.exe!_RTC_UninitUse
mysqld-debug.exe!do_select
mysqld-debug.exe!JOIN::exec
mysqld-debug.exe!subselect_single_select_engine::exec
mysqld-debug.exe!Item_subselect::exec
mysqld-debug.exe!Item_singlerow_subselect::val_int
mysqld-debug.exe!Arg_comparator::compare_int_signed
mysqld-debug.exe!Arg_comparator::compare
mysqld-debug.exe!Item_func_eq::val_int
mysqld-debug.exe!Item_equal::add
mysqld-debug.exe!Item_equal::update_const
mysqld-debug.exe!update_const_equal_items
mysqld-debug.exe!join_read_const_table
mysqld-debug.exe!make_join_statistics
mysqld-debug.exe!JOIN::optimize
mysqld-debug.exe!mysql_select
mysqld-debug.exe!mysql_explain_union
mysqld-debug.exe!mysql_execute_command
mysqld-debug.exe!mysql_parse
mysqld-debug.exe!dispatch_command
mysqld-debug.exe!do_command
mysqld-debug.exe!handle_one_connection
mysqld-debug.exe!pthread_start
mysqld-debug.exe!_callthreadstart
mysqld-debug.exe!_threadstart
kernel32.dll!FlsSetValue

Here's the code place mentioned:

if (!join->conds || join->conds->val_int())
{
  error= (*end_select)(join,join_tab,0);
  if (error == NESTED_LOOP_OK || error == NESTED_LOOP_QUERY_LIMIT)
    error= (*end_select)(join,join_tab,1);
}

join_tab has a value of 0xcccccccc
Although the function that is called has join_tab declared as
__attribute__((unused)), how can this always be guaranteed ?

At least it can make our full debug binaries difficult to
use when doing normal testing.

This testcase doesn't cause a crash if the warning message is ignored.

How to repeat:
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` ( `c1` char(50), `c2` int) ENGINE=MyISAM;
INSERT INTO `t1` VALUES ('a',1);
EXPLAIN SELECT * FROM `t1` WHERE `c2` =  (SELECT max(2));

Suggested fix:
initialize the join_tab to NULL if it's not going to be used.
[13 Apr 2007 14:44] Shane Bester
stack from the debugger break

Attachment: bug27811_full_stack_5.0.40_debug_windows.txt (text/plain), 3.15 KiB.

[20 Apr 2007 16:01] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/25022

ChangeSet@1.2459, 2007-04-20 19:01:30+03:00, gkodinov@magare.gmz +3 -0
  Bug #27811: 
   FORCE_INIT_OF_VARS was not defined for the 
   debug builds on Windows. This caused LINT_INIT
   macro to be defined as NOP and this triggers
   false alarms about use of uninitialized with
   the runtime libs of some Visual Studio versions.
   Fixed by defining FORCE_INIT_OF_VARS to match the
   state of the Windows
[30 Apr 2007 12:58] Bugs System
Pushed into 5.0.42
[30 Apr 2007 12:58] Bugs System
Pushed into 5.1.18-beta
[8 May 2007 1:21] Paul DuBois
Noted in 5.0.42, 5.1.18 changelogs.

Debug builds on Windows generated false alarms about uninitialized
variables with some Visual Studio runtime libraries.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.054 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.