Bug 887597

Summary: xloadimage has a memory leak and will crash if enough images are viewed and does not work with delays <1second.
Product: [Fedora] Fedora Reporter: Roger Heflin <rahhorizon>
Component: xloadimageAssignee: Tom "spot" Callaway <tcallawa>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 17CC: tcallawa
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-01-12 14:59:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Roger Heflin 2012-12-16 18:15:04 UTC
Description of problem:

Xloadimage has a memory leak and will crash if enough images are viewed one after another.    I include the patch to correct the issue, and an additional patch to adjust the -delay option to allow <1second delays, the delay patch does not change the way xloadimage works except for allowing <1 second decimal values to work.   Man page does not indicate that only integers are allowed, and it seems reasonable to allow <1 second delays.


Version-Release number of selected component (if applicable):
Fedora 17


How reproducible:
Likely only crashes on 32bit, on 64 bit will have excessive memory consumption and probably page excessively.


Steps to Reproduce:
1.   xloadimage  *.jpg with enough images and hit N until it crashes...it may not crash on 64bit but the machine will eventually start paging, on 32bit it will crash when it hits around 2GB.
2.   hit n until it crashes, with ps one can see that with each image viewed the memory size is growing.
3.
  
Actual results:
it crashes.

Expected results:
no crash.

Additional info:
Patches:

Patch to fix bug:
-- new.c.orig	2012-12-16 11:15:06.753666740 -0600
+++ new.c	2012-12-16 11:15:28.042023127 -0600
@@ -181,7 +181,7 @@
   image->depth= 24;
   image->pixlen= 3;
   image->data= (unsigned char *)lmalloc(ovmul(ovmul(width, height), 3));
-  image->data= (unsigned char *)lmalloc(width * height * 3);
+/*  image->data= (unsigned char *)lmalloc(width * height * 3); */
   return(image);
 }
 


Patches to add -delay <1 functionality, delay otherwise still works exactly as is described in the man page just allowing <1 second to be valid.

--- options.c.orig	2012-12-16 11:16:05.147899943 -0600
+++ options.c	2012-12-16 11:16:41.897787363 -0600
@@ -720,7 +720,7 @@
       
       continue;
 #else /* !NO_DELAY */
-      newopt->info.delay= getInteger(DELAY, argv[a]);
+      newopt->info.delay= getFloat(DELAY, argv[a]);
       break;
 #endif /* !NO_DELAY */
 
--- options.h.orig	2012-12-16 11:16:09.440769951 -0600
+++ options.h	2012-12-16 11:17:20.620614643 -0600
@@ -49,7 +49,7 @@
       unsigned int x, y, w, h; /* area of image to be used */
     } clip;
     unsigned int  colors;     /* max # of colors to use for this image */
-    unsigned int  delay;      /* # of seconds delay before auto pic advance */
+    double  delay;      /* # of seconds delay before auto pic advance */
     char         *display;    /* display name */
     struct {
       char *type; /* image type */
--- window.c.orig	2012-12-16 11:42:35.779494949 -0600
+++ window.c	2012-12-16 11:44:52.846362310 -0600
@@ -583,9 +583,9 @@
   install= (getOption(global_options, INSTALL) != NULL);
   private_cmap= (getOption(global_options, PRIVATE) != NULL);
   if ((opt= getOption(image_options, DELAY)))
-    delay= opt->info.delay;
+    delay= opt->info.delay*1000000;
   else if ((opt= getOption(global_options, DELAY)))
-    delay= opt->info.delay;
+    delay= opt->info.delay*1000000;
   else
     delay= 0;
   if ((opt= getOption(image_options, VISUAL)))
@@ -872,7 +872,7 @@
 #ifdef ENABLE_TIMEOUT
       AlarmWentOff = 0;
       signal(SIGALRM, delayAlarmHandler);
-      alarm(delay);
+      ualarm(delay,0);
 #endif /* ENABLE_TIMEOUT */
   }

Comment 1 Tom "spot" Callaway 2012-12-17 15:17:11 UTC
*** Bug 887598 has been marked as a duplicate of this bug. ***

Comment 2 Roger Heflin 2012-12-20 03:29:31 UTC
updated patch for window.c (ualarm does not work >999999 us):
--- window.c.orig	2012-12-16 11:42:35.779494949 -0600
+++ window.c	2012-12-19 21:25:48.179115901 -0600
@@ -583,9 +583,9 @@
   install= (getOption(global_options, INSTALL) != NULL);
   private_cmap= (getOption(global_options, PRIVATE) != NULL);
   if ((opt= getOption(image_options, DELAY)))
-    delay= opt->info.delay;
+    delay= opt->info.delay*1000000;
   else if ((opt= getOption(global_options, DELAY)))
-    delay= opt->info.delay;
+    delay= opt->info.delay*1000000;
   else
     delay= 0;
   if ((opt= getOption(image_options, VISUAL)))
@@ -872,7 +872,10 @@
 #ifdef ENABLE_TIMEOUT
       AlarmWentOff = 0;
       signal(SIGALRM, delayAlarmHandler);
-      alarm(delay);
+      if (delay > 999999)
+        alarm(delay/1000000);
+      else
+        ualarm(delay,0);
 #endif /* ENABLE_TIMEOUT */
   }

Comment 3 Fedora Update System 2013-01-02 18:51:03 UTC
xloadimage-4.1-13.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/xloadimage-4.1-13.fc17

Comment 4 Fedora Update System 2013-01-02 18:51:13 UTC
xloadimage-4.1-13.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/xloadimage-4.1-13.fc18

Comment 5 Fedora Update System 2013-01-03 07:23:23 UTC
Package xloadimage-4.1-13.fc17:
* should fix your issue,
* was pushed to the Fedora 17 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing xloadimage-4.1-13.fc17'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-0108/xloadimage-4.1-13.fc17
then log in and leave karma (feedback).

Comment 6 Fedora Update System 2013-01-12 14:59:09 UTC
xloadimage-4.1-13.fc17 has been pushed to the Fedora 17 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 7 Fedora Update System 2013-01-12 15:00:33 UTC
xloadimage-4.1-13.fc18 has been pushed to the Fedora 18 stable repository.  If problems still persist, please make note of it in this bug report.