[vtk-developers] [VTK 0011613]: vtkOpenGLImageActor hangs if image is empty.

Mantis Bug Tracker mantis at public.kitware.com
Thu Dec 16 09:29:35 EST 2010


The following issue has been SUBMITTED. 
====================================================================== 
http://www.paraview.org/Bug/view.php?id=11613 
====================================================================== 
Reported By:                John Stark.
Assigned To:                
====================================================================== 
Project:                    VTK
Issue ID:                   11613
Category:                   (No Category)
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2010-12-16 09:29 EST
Last Modified:              2010-12-16 09:29 EST
====================================================================== 
Summary:                    vtkOpenGLImageActor hangs if image is empty.
Description: 
When an empty image is passed to the vtkOpenGLImageActor, the MakeDataSuitable
method can enter an infinite loop, and hang. 

The problem only occurs when the image returns it's extents as [0, -1, 0, -1, 0,
-1]. In this case, the xsize is inferred to be -1, and the loop to find the next
power of 2 falls into an infinite loop. 


Additional Information: 
The problem occurs here : 
    xsize = ext[xdim*2+1] - ext[xdim*2] + 1;
    // xsize and ysize must be a power of 2 in OpenGL
    xs = static_cast<unsigned short>(xsize);
    while (!(xs & 0x01))
      {
      xs = xs >> 1;
      }

If xs is zero, the loop never terminates. 
Please can you add an additional test that both xsize and ysize are > zero :
diff --git a/Rendering/vtkOpenGLImageActor.cxx
b/Rendering/vtkOpenGLImageActor.cxx
index 172b82a..79ee1a8 100644
--- a/Rendering/vtkOpenGLImageActor.cxx
+++ b/Rendering/vtkOpenGLImageActor.cxx
@@ -154,9 +154,12 @@ unsigned char *vtkOpenGLImageActor::MakeDataSuitable(int
&xsize, int &ysize,
     xsize = ext[xdim*2+1] - ext[xdim*2] + 1;
     // xsize and ysize must be a power of 2 in OpenGL
     xs = static_cast<unsigned short>(xsize);
-    while (!(xs & 0x01))
+    if (xsize > 0)
       {
-      xs = xs >> 1;
+      while (!(xs & 0x01))
+        {
+        xs = xs >> 1;
+        }
       }
     if (xs == 1)
       {
@@ -170,9 +173,12 @@ unsigned char *vtkOpenGLImageActor::MakeDataSuitable(int
&xsize, int &ysize,
     ysize = (this->ComputedDisplayExtent[ydim*2+1] -
              this->ComputedDisplayExtent[ydim*2] + 1);
     ys = static_cast<unsigned short>(ysize);
-    while (!(ys & 0x01))
+    if (ysize > 0)
       {
-      ys = ys >> 1;
+      while (!(ys & 0x01))
+        {
+        ys = ys >> 1;
+        }
       }
     // yes it is a power of two already
     if (ys == 1)
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2010-12-16 09:29 John Stark.    New Issue                                    
======================================================================




More information about the vtk-developers mailing list