Bug #60907 mysql-test/lib/My/SafeProcess/safe_process.pl uses hardcoded signal numbers
Submitted: 18 Apr 2011 19:47 Modified: 13 May 2011 13:50
Reporter: Paul Green (OCA) Email Updates:
Status: Closed Impact on me:
Category:Tools: MTR / mysql-test-run Severity:S3 (Non-critical)
Version:5.6.2-m5 OS:Any
Assigned to: Bjørn Munch CPU Architecture:Any
Tags: Contribution

[18 Apr 2011 19:47] Paul Green
The file mysql/mysql-test/lib/My/SafeProcess/safe_process.pl contains 2 numeric references (==9) to the SIGKILL signal. These should be symbolic references (=='KILL').

The reason for this report is that neither the C-99 nor the POSIX-2008 standards specify a binding between signal numbers and signal names; hence, this method of coding can cause issues on otherwise POSIX-compliant implementations that happen to use a different signal numbering scheme than Linux or Unix.

As far as I can tell, all other references to signals in the perl scripts have already been converted to symbolic references. These are the only remaining numeric references that I can find. I searched for 'kill' and '$SIG'.

Note: The behavior of "kill(0, ...)" is well-defined by the POSIX standard and should not be changed. 

I ran across this issue in MySQL 5.1.48; I have just verified that it still exists in MySQL 5.6.2-m5.

I have submitted a SCA in the past; it should still be on file; if not, let me know and I will submit a new one.

How to repeat:
The error can be found by visually inspecting the perl scripts, looking at the first argument to the "kill" function, and for references to the $SIG vector. See the text below, under "Suggested fix", for an example of such references.

Suggested fix:
Index: trunk/2.0/mysql/mysql-test/lib/My/SafeProcess/safe_process.pl
--- trunk/2.0/mysql/mysql-test/lib/My/SafeProcess/safe_process.pl     (revision 41)
+++ trunk/2.0/mysql/mysql-test/lib/My/SafeProcess/safe_process.pl     (revision 42)
@@ -94,7 +94,7 @@
   local $SIG{INT}=  \&handle_signal;
   local $SIG{CHLD}= sub {
     message("Got signal @_");
-    kill(9, -$child_pid);
+    kill('KILL', -$child_pid);
     my $ret= waitpid($child_pid, 0);
     if ($? & 127){
       exit(65); # Killed by signal
@@ -134,7 +134,7 @@
 # Use negative pid in order to kill the whole
 # process group
-my $ret= kill(9, -$child_pid);
+my $ret= kill('KILL', -$child_pid);
 message("Killed child: $child_pid, ret: $ret");
 if ($ret > 0) {
   message("Killed child: $child_pid");
[18 Apr 2011 20:23] MySQL Verification Team
Thank you for the bug report.
[19 Apr 2011 14:49] Paul Green
I ran into this issue while porting MySQL 5.1.48 to the Stratus OpenVOS operating system, Release 17.1.
[28 Apr 2011 7:58] Bjørn Munch
Changed to more appropriate category. Thanks for pointing this out, it's being fixed.
[13 May 2011 13:50] Bjørn Munch
Fixed in 5.1.58, 5.5.13, 5.6.3
[13 May 2011 13:52] Bjørn Munch
Changeset: http://lists.mysql.com/commits/135808