[torquedev] Patch for buglets in 2.3.1 found by GCC (was: TORQUE 2.3.1 Released)

Tobias Burnus burnus at net-b.de
Thu Jul 3 12:26:53 MDT 2008


Hello,


First, compiling 2.3.1 fails here with:
|
cc1: warnings being treated as errors
mom_server.c: In function 'is_mom_server_down':
mom_server.c:2536: error: array subscript is above array bounds


I believe that the logic of the for loop is wrong and the following 
patch is correct. Please check - especially check whether "==" or "!=" 
is correct.

|||

--- ../torque-2.3.1.orig/src/resmom/mom_server.c        2008-07-02 23:01:03.000000000 +0200
+++ src/resmom/mom_server.c     2008-07-03 19:31:56.000000000 +0200
@@ -2533,7 +2533,7 @@ is_mom_server_down(pbs_net_t server_addr
   {
   int sindex;

-  for (sindex = 0; sindex < PBS_MAXSERVER || down_svraddrs[sindex] == 0; sindex++)
+  for (sindex = 0; sindex < PBS_MAXSERVER && down_svraddrs[sindex] != 0; sindex++)
     {
     if (down_svraddrs[sindex] == server_address)
       {



Fixing it, it fails with:

|cc1: warnings being treated as errors
start_exec.c: In function 'std_file_name':
start_exec.c:5289: error: comparison with string literal results in unspecified behavior


Which is fixed by:

--- ../torque-2.3.1.orig/src/resmom/start_exec.c        2008-07-02 22:57:23.000000000 +0200
+++ src/resmom/start_exec.c     2008-07-03 20:10:14.000000000 +0200
@@ -5286,7 +5286,7 @@

     /* don't do for checkpoint file names, only StdErr and StdOut */

-    if (suffix != JOB_CKPT_SUFFIX)
+    if (strcmp(suffix, JOB_CKPT_SUFFIX) != 0)
       {
       pt = strstr(jobpath,"$HOME");


|

Secondly, it would be great if for 2.3.2 the invalid-memory-access bug in qsub could be fixed.
http://www.clusterresources.com/pipermail/torquedev/2008-July/001119.html


Thirdly, with all checking turned on, I need the attached patch in order to build Torque; please consider including them - especially prototype.patch.

Regards,

Tobias

-------------- next part --------------
Thu, 03 Jul 2008 18:54:51 +0200  Tobias Burnus  <burnus at net-b.de>

  Fix rpmlint errors: Return value of fwrite/fread was not checked.

diff -ur ../torque-2.3.1.orig/src/resmom/linux/cpuset.c ./src/resmom/linux/cpuset.c
--- ../torque-2.3.1.orig/src/resmom/linux/cpuset.c	2008-06-13 01:01:03.000000000 +0200
+++ ./src/resmom/linux/cpuset.c	2008-07-03 18:51:04.000000000 +0200
@@ -139,7 +139,11 @@
         strcat(path,"/cpus");
         fd=fopen(path,"r");
 if (fd) {  /* FIXME: need proper error checking and response */
-        fread(cpuset_buf, sizeof(char), 1023, fd);
+        if (!fread(cpuset_buf, sizeof(char), 1023, fd))
+          {
+	    perror("Readings cpus");
+            exit(1);
+          }
         fclose(fd);
         strcpy(path,TCPUSET_PATH);
         strcat(path,"/cpus");
@@ -147,7 +151,11 @@
 if (fd) {
 sprintf (log_buffer, "adding %s to %s",cpuset_buf,path);
 log_err(-1,id,log_buffer);
-        fwrite(cpuset_buf, sizeof(char), strlen(cpuset_buf), fd);
+        if(!fwrite(cpuset_buf, sizeof(char), strlen(cpuset_buf), fd))
+          {
+	    perror("Writing cpus");
+            exit(1);
+          }
         fclose(fd);
 }
 	memset(cpuset_buf,'\0',sizeof(cpuset_buf));
@@ -158,7 +166,11 @@
         strcat(path,"/mems");
         fd=fopen(path,"r");
 if (fd) {
-        fread(cpuset_buf, sizeof(char), 1023, fd);
+        if (!fread(cpuset_buf, sizeof(char), 1023, fd))
+          {
+	    perror("Readings mems");
+            exit(1);
+          }
         fclose(fd);
         strcpy(path,TCPUSET_PATH);
         strcat(path,"/mems");
@@ -166,7 +178,11 @@
 if (fd) {
 sprintf (log_buffer, "adding %s to %s",cpuset_buf,path);
 log_err(-1,id,log_buffer);
-        fwrite(cpuset_buf, sizeof(char), strlen(cpuset_buf), fd);
+        if (!fwrite(cpuset_buf, sizeof(char), strlen(cpuset_buf), fd))
+          {
+	    perror("Writing mems");
+            exit(1);
+          }
         fclose(fd);
 }
 	memset(cpuset_buf,'\0',sizeof(cpuset_buf));
@@ -258,12 +274,20 @@
   strcat(rootpath,"/mems");
   fd=fopen(rootpath,"r");
 if (fd) {
-  fread(cpusbuf, sizeof(char), 1023, fd);
+  if (!fread(cpusbuf, sizeof(char), 1023, fd))
+    {
+      perror("Readings mems");
+      exit(1);
+    }
   fclose(fd);
   strcpy(tmppath,path);
   strcat(tmppath,"/mems");
   fd=fopen(tmppath,"w");
-  fwrite(cpusbuf, sizeof(char), strlen(cpusbuf), fd);
+  if (fwrite(cpusbuf, sizeof(char), strlen(cpusbuf), fd))
+    {
+      perror("Writing mems");
+      exit(1);
+    }
   fclose(fd);
   memset(cpusbuf,'\0',sizeof(cpusbuf));
 }
@@ -294,7 +318,12 @@
 log_err(-1,id,log_buffer);
   fd=fopen(tmppath,"w");
 if (fd) {
-  fwrite(cpusbuf, sizeof(char), strlen(cpusbuf), fd);
+  if (!fwrite(cpusbuf, sizeof(char), strlen(cpusbuf), fd))
+    {
+      perror("Writing cpu sets");
+      exit(1);
+    }
+
   fclose(fd);
 }
 	memset(cpusbuf,'\0',sizeof(cpusbuf));
@@ -316,7 +345,11 @@
 log_err(-1,id,log_buffer);
       fd=fopen(tmppath,"w");
 if (fd) {
-      fwrite(tasksbuf, sizeof(char), strlen(tasksbuf), fd);
+      if (!fwrite(tasksbuf, sizeof(char), strlen(tasksbuf), fd))
+        {
+          perror("Writing cpus");
+          exit(1);
+        }
       fclose(fd);
 }
       memset(tasksbuf,'\0',sizeof(tasksbuf));
@@ -326,7 +359,11 @@
         sprintf(tmppath,"%s/%s/%s",TCPUSET_PATH,pjob->ji_qs.ji_jobid,"/mems");
         fd=fopen(tmppath,"r");
 if (fd) {
-        fread(tasksbuf, sizeof(char), 1023, fd);
+        if (!fread(tasksbuf, sizeof(char), 1023, fd))
+          {
+            perror("Reading tasksets");
+            exit(1);
+          }
         fclose(fd);
 }
         sprintf(tmppath,"%s/%s/%d/%s",TCPUSET_PATH,pjob->ji_qs.ji_jobid,np->vn_node,"/mems");
@@ -334,7 +371,11 @@
 if (fd) {
 sprintf (log_buffer, "adding %s to %s",tasksbuf,tmppath);
 log_err(-1,id,log_buffer);
-        fwrite(tasksbuf, sizeof(char), strlen(tasksbuf), fd);
+        if (!fwrite(tasksbuf, sizeof(char), strlen(tasksbuf), fd))
+        {
+          perror("Writing tasksets");
+          exit(1);
+        }
         fclose(fd);
 }
         memset(tasksbuf,'\0',sizeof(tasksbuf));
@@ -366,7 +407,11 @@
   
   fd=fopen(taskspath,"w");
 if (fd) {
-  fwrite(pidbuf,sizeof(char),strlen(pidbuf),fd);
+  if (!fwrite(pidbuf,sizeof(char),strlen(pidbuf),fd))
+    {
+      perror("Writing pid buffer");
+      exit(1);
+    }
   fclose(fd);
 }
   memset(pidbuf,'\0',sizeof(pidbuf));
@@ -393,7 +438,11 @@
   
   fd=fopen(taskspath,"w");
 if (fd) {
-  fwrite(pidbuf,sizeof(char),strlen(pidbuf),fd);
+  if (!fwrite(pidbuf,sizeof(char),strlen(pidbuf),fd))
+    {
+      perror("Writing pid buffer");
+      exit(1);
+    }
   fclose(fd);
 }
   memset(pidbuf,'\0',sizeof(pidbuf));
-------------- next part --------------
Tue Apr  1 18:14:02 CEST 2008  Tobias Burnus  <burnus at net-b.de>

  'freopen' is declared with attribute warn_unused_result
  and torque build with -Werror. The return value of freopen is now checked.

diff -ur ../torque-2.3.0.orig/src/scheduler.cc/pbs_sched.c ./src/scheduler.cc/pbs_sched.c
--- ../torque-2.3.0.orig/src/scheduler.cc/pbs_sched.c	2008-03-06 22:29:03.000000000 +0100
+++ ./src/scheduler.cc/pbs_sched.c	2008-04-01 18:11:58.000000000 +0200
@@ -981,7 +981,13 @@
 
           lock_out(lockfds, F_WRLCK);
 
-          freopen(dbfile, "a", stdout);
+          if (freopen(dbfile, "a", stdout) == NULL)
+            {
+            perror("opening lockfile");
+
+            exit(1);
+            }
+
 
           setvbuf(stdout, NULL, _IOLBF, 0);
 
@@ -995,7 +1001,12 @@
           pid = getpid();
           }
 
-        freopen("/dev/null", "r", stdin);
+        if (freopen("/dev/null", "r", stdin) == NULL)
+            {
+            perror("opening /dev/null");
+
+            exit(1);
+            }
 
         /* write scheduler's pid into lockfile */
 
-------------- next part --------------
Thu, 03 Jul 2008 19:09:06 +0200  Tobias Burnus  <burnus at net-b.de>

  init.d LSB conformance fixes.

diff -ur ../torque-2.3.1.orig/contrib/init.d/suse.pbs_mom contrib//init.d/suse.pbs_mom
--- ../torque-2.3.1.orig/contrib/init.d/suse.pbs_mom	2008-03-06 22:29:09.000000000 +0100
+++ contrib//init.d/suse.pbs_mom	2008-07-03 19:41:01.000000000 +0200
@@ -4,13 +4,16 @@
 #
 ### BEGIN INIT INFO
 # Provides:       pbs_mom
-# Required-Start: $local_fs
+# Required-Start: $syslog $remote_fs
 # Should-Start: pbs_server pbs_sched
-# Required-Stop:
+# Required-Stop: $syslog $remote_fs
 # Should-Stop:
 # Default-Start:  2 3 5
 # Default-Stop:
-# Description: Torque is a versatile batch system for SMPs and clusters
+# Short-Description: Torque Node Manager Daemon
+# Description: Torque is a versatile batch system for SMPs and clusters.
+#	This starts the operation of a batch Machine Oriented Mini-server,
+#	MOM, on the local host.
 ### END INIT INFO
 
 PBS_DAEMON=/usr/sbin/pbs_mom
diff -ur ../torque-2.3.1.orig/contrib/init.d/suse.pbs_sched contrib//init.d/suse.pbs_sched
--- ../torque-2.3.1.orig/contrib/init.d/suse.pbs_sched	2008-03-06 22:29:09.000000000 +0100
+++ contrib//init.d/suse.pbs_sched	2008-07-03 19:41:05.000000000 +0200
@@ -4,13 +4,18 @@
 #
 ### BEGIN INIT INFO
 # Provides:       pbs_sched
-# Required-Start: $local_fs
+# Required-Start: $syslog $remote_fs
 # Should-Start: pbs_server
-# Required-Stop:
+# Required-Stop: $syslog $remote_fs
 # Should-Stop:
 # Default-Start:  2 3 5
 # Default-Stop:
-# Description: Torque is a versatile batch system for SMPs and clusters
+# Short-Description: Torque scheduler
+# Description: Torque is a versatile batch system for SMPs and clusters.
+#	Starts the PBS scheduler, which runs in conjunction with the PBS server.
+#	it queries the server about the state of PBS and communicates with
+#	pbs_resmon to get information about the status of running jobs, memory
+#	available etc.  It then makes decisions as to what jobs to run.
 ### END INIT INFO
 
 PBS_DAEMON=/usr/sbin/pbs_sched
diff -ur ../torque-2.3.1.orig/contrib/init.d/suse.pbs_server contrib//init.d/suse.pbs_server
--- ../torque-2.3.1.orig/contrib/init.d/suse.pbs_server	2008-03-06 22:29:09.000000000 +0100
+++ contrib//init.d/suse.pbs_server	2008-07-03 19:08:02.000000000 +0200
@@ -4,13 +4,16 @@
 #
 ### BEGIN INIT INFO
 # Provides:       pbs_server
-# Required-Start: $local_fs
+# Required-Start: $syslog $remote_fs
 # Should-Start:
-# Required-Stop:
+# Required-Stop: $syslog $remote_fs
 # Should-Stop:
 # Default-Start:  2 3 5
 # Default-Stop:
-# Description: Torque is a versatile batch system for SMPs and clusters
+# Short-Description: Torque server
+# Description: Torque is a versatile batch system for SMPs and clusters.
+#	Starts the PBS batch server, which operates as batch server
+#	on the local host.
 ### END INIT INFO
 
 PBS_DAEMON=/usr/sbin/pbs_server
-------------- next part --------------
Thu Apr 24 10:32:28 CEST 2008  Tobias Burnus  <burnus at net-b.de>

	Fix prototype declaration for -Wunprototyped-calls.


diff -r -p -u ../torque-2.3.0.orig//doc/soelim.c .//doc/soelim.c
--- ../torque-2.3.0.orig//doc/soelim.c	2008-03-06 22:29:12.000000000 +0100
+++ .//doc/soelim.c	2008-04-24 14:57:55.000000000 +0200
@@ -102,7 +102,7 @@ int main(argc, argv)
 	int argc;
 	char *argv[];
 {
-	int   dofile();
+	int   dofile(FILE *);
 	int   dirct = 0;
 	FILE *filein;
 	int   i;
diff -r -p -u ../torque-2.3.0.orig//src/cmds/qdisable.c .//src/cmds/qdisable.c
--- ../torque-2.3.0.orig//src/cmds/qdisable.c	2008-03-06 22:28:55.000000000 +0100
+++ .//src/cmds/qdisable.c	2008-04-24 13:19:46.000000000 +0200
@@ -110,7 +110,7 @@
 
 int exitstatus = 0; /* Exit Status */
 
-static void execute ();
+static void execute (char *, char *);
 
 int main ( argc, argv )
 int argc;
diff -r -p -u ../torque-2.3.0.orig//src/cmds/qenable.c .//src/cmds/qenable.c
--- ../torque-2.3.0.orig//src/cmds/qenable.c	2008-03-06 22:28:55.000000000 +0100
+++ .//src/cmds/qenable.c	2008-04-24 13:27:49.000000000 +0200
@@ -109,7 +109,7 @@
 
 
 int exitstatus = 0; /* Exit Status */
-static void execute ();
+static void execute (char *, char *);
 
 
 int main(
diff -r -p -u ../torque-2.3.0.orig//src/cmds/qrun.c .//src/cmds/qrun.c
--- ../torque-2.3.0.orig//src/cmds/qrun.c	2008-03-06 22:28:55.000000000 +0100
+++ .//src/cmds/qrun.c	2008-04-24 13:36:27.000000000 +0200
@@ -101,7 +101,7 @@
 #include <pbs_config.h>   /* the master config generated by configure */
 
 int exitstatus = 0; /* Exit Status */
-static void execute();
+static void execute(char *, char *, char *, int);
 
 
 
diff -r -p -u ../torque-2.3.0.orig//src/cmds/qstart.c .//src/cmds/qstart.c
--- ../torque-2.3.0.orig//src/cmds/qstart.c	2008-03-06 22:28:55.000000000 +0100
+++ .//src/cmds/qstart.c	2008-04-24 13:36:39.000000000 +0200
@@ -108,7 +108,7 @@
 
 
 int exitstatus = 0; /* Exit Status */
-static void execute ();
+static void execute (char *, char *);
 
 
 int main ( 
diff -r -p -u ../torque-2.3.0.orig//src/cmds/qstop.c .//src/cmds/qstop.c
--- ../torque-2.3.0.orig//src/cmds/qstop.c	2008-03-06 22:28:55.000000000 +0100
+++ .//src/cmds/qstop.c	2008-04-24 13:36:48.000000000 +0200
@@ -108,7 +108,7 @@
 
 
 int exitstatus = 0; /* Exit Status */
-static void execute ();
+static void execute (char *, char *);
 
 
 int main ( argc, argv )
diff -r -p -u ../torque-2.3.0.orig//src/cmds/qterm.c .//src/cmds/qterm.c
--- ../torque-2.3.0.orig//src/cmds/qterm.c	2008-03-06 22:28:55.000000000 +0100
+++ .//src/cmds/qterm.c	2008-04-24 13:37:00.000000000 +0200
@@ -113,7 +113,7 @@
 
 int exitstatus = 0; /* Exit Status */
 
-static void execute();
+static void execute(int, char *);
 
 int main(
 
diff -r -p -u ../torque-2.3.0.orig//src/include/md5.h .//src/include/md5.h
--- ../torque-2.3.0.orig//src/include/md5.h	2008-03-06 22:28:54.000000000 +0100
+++ .//src/include/md5.h	2008-04-24 13:03:03.000000000 +0200
@@ -55,9 +55,9 @@ typedef struct {
   unsigned char digest[16];     /* actual digest after MD5Final call */
 } MD5_CTX;
 
-void MD5Init ();
-void MD5Update ();
-void MD5Final ();
+void MD5Init (MD5_CTX *);
+void MD5Update (MD5_CTX *, unsigned char *, unsigned int);
+void MD5Final (MD5_CTX *);
 
 #define __MD5_INCLUDE__
 #endif /* __MD5_INCLUDE__ */
diff -r -p -u ../torque-2.3.0.orig//src/include/mom_func.h .//src/include/mom_func.h
--- ../torque-2.3.0.orig//src/include/mom_func.h	2008-03-06 22:28:54.000000000 +0100
+++ .//src/include/mom_func.h	2008-04-24 12:52:13.000000000 +0200
@@ -149,7 +149,7 @@ extern void  set_globid A_((job *, struc
 extern int   set_mach_vars A_((job *, struct var_table *));
 extern char *set_shell A_((job *, struct passwd *));
 extern void  start_exec A_((job *));
-extern int   open_master();
+extern int   open_master(char **);
 extern int   open_slave();
 extern char *rcvttype A_((int));
 extern int   rcvwinsize A_((int));
diff -r -p -u ../torque-2.3.0.orig//src/include/qmgr.h .//src/include/qmgr.h
--- ../torque-2.3.0.orig//src/include/qmgr.h	2008-03-06 22:28:54.000000000 +0100
+++ .//src/include/qmgr.h	2008-04-24 14:14:18.000000000 +0200
@@ -166,30 +166,30 @@ struct objname
 
 
 /* prototypes */
-struct objname *commalist2objname();
-struct server *find_server();
+struct objname *commalist2objname(char *, int);
+struct server *find_server(char *);
 struct server *make_connection();
 struct server *new_server();
 struct objname *new_objname();
-struct objname *strings2objname( );
+struct objname *strings2objname(char **, int, int);
 struct objname *default_server_name();
-struct objname *temp_objname();
-int parse_request( );
-void clean_up_and_exit();
-void freeattrl();
-void freeattropl();
-void pstderr_big();
-void free_objname_list();
-void free_server();
-void free_objname();
+struct objname *temp_objname(char *, char *, struct server *);
+int parse_request(char *, char [][MAX_REQ_WORD_LEN]);
+void clean_up_and_exit(int);
+void freeattrl(struct attrl *);
+void freeattropl(struct attropl *);
+void pstderr_big(char *, char*, char *);
+void free_objname_list(struct objname *);
+void free_server(struct server *);
+void free_objname(struct objname *);
 void close_non_ref_servers();
-int connect_servers();
-int set_active();
-int get_request();
-int parse();
-int execute();
-int is_attr();
-int is_valid_object();
+int connect_servers(struct objname *, int);
+int set_active(int, struct objname *);
+int get_request(char *);
+int parse(char *, int *, int *, char **, struct attropl **);
+int execute(int, int, int, char *, struct attropl *);
+int is_attr(int, char *, int);
+int is_valid_object(struct objname *, int);
 void disconnect_from_server();
 
 
diff -r -p -u ../torque-2.3.0.orig//src/lib/Libnet/md5.c .//src/lib/Libnet/md5.c
--- ../torque-2.3.0.orig//src/lib/Libnet/md5.c	2008-03-06 22:29:09.000000000 +0100
+++ .//src/lib/Libnet/md5.c	2008-04-24 10:27:41.000000000 +0200
@@ -49,7 +49,7 @@
  */
 
 /* forward declaration */
-static void Transform ();
+static void Transform (UINT4 *, UINT4 *);
 
 static unsigned char PADDING[64] = {
   0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
diff -r -p -u ../torque-2.3.0.orig//src/lib/Libnet/net_server.c .//src/lib/Libnet/net_server.c
--- ../torque-2.3.0.orig//src/lib/Libnet/net_server.c	2008-03-06 22:29:09.000000000 +0100
+++ .//src/lib/Libnet/net_server.c	2008-04-24 11:08:33.000000000 +0200
@@ -115,7 +115,7 @@ extern int LOGLEVEL;
 
 extern void process_request A_((int));
 
-extern time_t time();
+extern time_t time(time_t *);
 
 /* Global Data (I wish I could make it private to the library, sigh, but
  * C don't support that scope of control.)
diff -r -p -u ../torque-2.3.0.orig//src/resmom/start_exec.c .//src/resmom/start_exec.c
--- ../torque-2.3.0.orig//src/resmom/start_exec.c	2008-03-06 22:29:05.000000000 +0100
+++ .//src/resmom/start_exec.c	2008-04-24 13:11:05.000000000 +0200
@@ -4644,9 +4644,9 @@ void start_exec(
 
     MD5Init(&c);
 
-    MD5Update(&c,(caddr_t)&loopcnt,sizeof(loopcnt));
+    MD5Update(&c,(unsigned char *)&loopcnt,sizeof(loopcnt));
 
-    MD5Update(&c,(caddr_t)pjob,sizeof(job));
+    MD5Update(&c,(unsigned char *)pjob,sizeof(job));
 
     MD5Final(&c);
 
diff -r -p -u ../torque-2.3.0.orig//src/server/req_stat.c .//src/server/req_stat.c
--- ../torque-2.3.0.orig//src/server/req_stat.c	2008-03-06 22:29:06.000000000 +0100
+++ .//src/server/req_stat.c	2008-04-24 11:56:13.000000000 +0200
@@ -119,7 +119,7 @@ extern attribute_def  node_attr_def[];
 extern int	       pbs_mom_port;
 extern time_t	       time_now;
 extern char	      *msg_init_norerun;
-extern struct pbsnode *tfind_addr();
+extern struct pbsnode *tfind_addr(const u_long);
 extern int             LOGLEVEL;
 
 /* Extern Functions */


More information about the torquedev mailing list