Bug #28012 Patch : IM crashes instead of reporting an error when mysqldpath is bad
Submitted: 22 Apr 2007 9:10 Modified: 2 Aug 2007 3:40
Reporter: Geoffroy Cogniaux Email Updates:
Status: Closed Impact on me:
None 
Category:Instance Manager Severity:S3 (Non-critical)
Version:5.1 BK OS:Microsoft Windows
Assigned to: Kristofer Pettersson CPU Architecture:Any
Tags: Contribution, Instance Manager

[22 Apr 2007 9:10] Geoffroy Cogniaux
Description:
Hi,

If the mysqld path option is not correctly set in my.ini file of Instance Manager, it crashes instead of reporting an error. We can see that at this step, instance_options->argv isn't initialized ( 0xcdcdcdcd under windows debugger ).

Call Stack of the Error :
>	mysqlmanager.exe!start_process(Instance_options * instance_options=0x00347790, _PROCESS_INFORMATION * pi=0x0314ff08)  Line 165 + 0x1e bytes	C++
 	mysqlmanager.exe!Instance_monitor::start_and_monitor_instance()  Line 346 + 0x10 bytes	C++
 	mysqlmanager.exe!Instance_monitor::run()  Line 315	C++
 	mysqlmanager.exe!Thread::thread_func(void * arg=0x00345550)  Line 358 + 0xe bytes	C++
 	mysqlmanager.exe!pthread_start(void * param=0x003455a0)  Line 61 + 0x9 bytes	C
 	mysqlmanager.exe!_callthreadstart()  Line 293 + 0xf bytes	C
 	mysqlmanager.exe!_threadstart(void * ptd=0x003455e8)  Line 277	C
 	kernel32.dll!7c80b50b() 	
 	[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]	
 	kernel32.dll!7c8399f3() 	

Values at the crash point :
-	instance_options	0x00347790 {pid_file_with_path=0x00347790 "" argv=0xcdcdcdcd mysqld_version=0x00000000 <Bad Ptr> ...}	Instance_options *
+		pid_file_with_path	0x00347790 ""	char [512]
+		argv	0xcdcdcdcd	char * *
+		mysqld_version	0x00000000 <Bad Ptr>	const char *
+		mysqld_socket	0x00000000 <Bad Ptr>	const char *
+		mysqld_datadir	0x00000000 <Bad Ptr>	const char *
+		mysqld_pid_file	0x00347f48 "mysqld5001-timor.pid"	const char *
+		instance_name	{str=0x00347c18 "mysqld5001" length=10 }	LEX_STRING
+		mysqld_path	{str=0x00347c28 "J:\_devel\_MySQL\farm\bin\mysqld-ntt.exe" length=40 }	LEX_STRING
+		mysqld_real_path	{str=0x00000000 <Bad Ptr> length=0 }	LEX_STRING
+		nonguarded	0x00000000 <Bad Ptr>	const char *
+		logs	0x003479c0	char * [3]
+		mysqld_port	0x00347ee8 "5001"	const char *
		mysqld_port_val	5001	unsigned int
+		shutdown_delay	0x00000000 <Bad Ptr>	const char *
		shutdown_delay_val	0	unsigned int
		filled_default_options	0	unsigned int
+		alloc	{free=0x00347c08 used=0x00000000 pre_alloc=0x00000000 ...}	st_mem_root
+		options	{initialized=1 arr={...} }	Named_value_arr

How to repeat:
Have a simple ini file like this :

# MySQL Instance Manager options section
[manager]
port = 1999
default-mysqld-path = J:/_devel/_MySQL/farm/bin/mysqld-ntttttttt.exe
[mysqld5001]
port = 5001

and run the command line :
mysqlmanager.exe --defaults-file=path_to\my.ini --password-file=path_to\mysqlmanager.passwd --standalone 

Suggested fix:
I suggest to initialize "instance_options->argv" to NULL and report the error in "Instance_monitor::start_and_monitor_instance()" when "start_process" fails.
[22 Apr 2007 9:12] Geoffroy Cogniaux
proposed patch

Attachment: bug28012.patch (text/plain), 1.63 KiB.

[3 May 2007 15:35] MySQL Verification Team
Thank you for the bug report.

>	mysqlmanager.exe!start_process(Instance_options * instance_options=0x01705720, _PROCESS_INFORMATION * pi=0x0416ff20)  Line 165 + 0x26 bytes	C++
 	mysqlmanager.exe!Instance_monitor::start_and_monitor_instance()  Line 343 + 0xe bytes	C++
 	mysqlmanager.exe!Instance_monitor::run()  Line 312	C++
 	mysqlmanager.exe!Thread::thread_func(void * arg=0x01705de0)  Line 360	C++
 	mysqlmanager.exe!_pthread_start()  + 0x3b bytes	C
 	mysqlmanager.exe!_callthreadstart()  Line 293 + 0x6 bytes	C
 	mysqlmanager.exe!_threadstart(void * ptd=0x017035f0)  Line 275 + 0x5 bytes	C
 	kernel32.dll!75c93833() 	
 	[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]	
 	ntdll.dll!772fa9bd()
[4 Jun 2007 21:20] Alexander Nozdrin
Actually, this bug is a duplicate of BUG#19043.

However, since this bug has more severity, marked as sr5_1 and has a patch,
I think, we should declare BUG#19043 as a duplicate of this one.
[23 Jul 2007 22:06] 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/31439

ChangeSet@1.2528, 2007-07-23 15:05:50+02:00, thek@adventure.(none) +6 -0
  Bug#28012 Patch : IM crashes instead of reporting an error when mysqldpath is bad
    
  On the windows platform, if an instance object failed to initialize during
  program start, the instance manager would crash.
  This could happen if an incorrect mysqld path was supplied in the 
  defaults configuration file.
  The patch prevents the program from crashing and makes it show an
  error message instead.
[24 Jul 2007 1:06] 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/31453

ChangeSet@1.2528, 2007-07-23 11:56:31+02:00, thek@adventure.(none) +3 -0
  Bug#28012 Patch : IM crashes instead of reporting an error when mysqldpath is bad
    
  On the windows platform, if an instance object failed to initialize during
  program start, the instance manager would crash.
  This could happen if an incorrect mysqld path was supplied in the 
  defaults configuration file.
  The patch prevents the program from crashing and makes it show an
  error message instead.
[24 Jul 2007 1:06] 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/31454

ChangeSet@1.2528, 2007-07-23 12:51:56+02:00, thek@adventure.(none) +4 -0
  Bug#28012 Patch : IM crashes instead of reporting an error when mysqldpath is bad
    
  On the windows platform, if an instance object failed to initialize during
  program start, the instance manager would crash.
  This could happen if an incorrect mysqld path was supplied in the 
  defaults configuration file.
  The patch prevents the program from crashing and makes it show an
  error message instead.
[1 Aug 2007 23:27] Bugs System
Pushed into 5.1.21-beta
[2 Aug 2007 3:40] Paul DuBois
Noted in 5.1.21 changelog.

On Windows, Instance Manager would crash if an instance object failed
to initialize during startup. This could happen if an incorrect
mysqld path was supplied in the configuration file.