On Sun, Jan 16, 2000 at 03:18:22AM +0100, Andreas Ehliar wrote:
> On Sun, Jan 16, 2000 at 02:14:37AM +0100, Andreas Ehliar wrote:
> > I'm getting a segfault in lambda_textured_triangle1 while running
> > Unreal Tournament. (Latest CVS, Mesa 3.2 branch, latest CVS of
> > the Unreal Tournament renderer as well.)
> > 
> > The segmentation fault  is reproducable, it happens after a while in the
> > demo that is running directly after starting up Unreal Tournament.
> > 
> > Program received signal SIGSEGV, Segmentation fault.
> > 0x41de4baf in lambda_textured_triangle1 (ctx=0xa3064d8, v0=3, v1=483, v2=484,
> >     pv=5, s=0xbfffc9f4, t=0xbfffb0f4, u=0xbfff97f4) at tritemp.h:952
> > 952                    INNER_LOOP( left, right, iy );
> > (gdb) p left
> > $1 = -1047998
> > Sounds pretty suspicious isn't it?
> > 
> > Full backtrace:
> > #0  0x41de4baf in lambda_textured_triangle1 (ctx=0xa3064d8, v0=3, v1=483,
> >     v2=484, pv=5, s=0xbfffc9f4, t=0xbfffb0f4, u=0xbfff97f4) at tritemp.h:952
> > #1  0x41deb54b in lambda_textured_triangle (ctx=0xa3064d8, v0=3, v1=483,
> >     v2=484, pv=5) at triangle.c:1432
> > #2  0x41df9162 in gl_render_clipped_triangle2 (ctx=0xa3064d8, v1=3, v2=4,
> >     v3=5, pv=5) at vbrender.c:242
> > #3  0x41df84ad in render_vb_tri_fan_clipped (VB=0xa318ce8, start=3, count=6,
> >     parity=0) at render_tmp.h:181
> > #4  0x41df8c03 in gl_render_vb () at render_tmp.h:274
> > #5  0x41d7af39 in gl_run_pipeline () at pipeline.c:395
> > #6  0x41dfc9ed in gl_execute_cassette () at vbxform.c:811
> > #7  0x41d0f935 in gl_cva_compile_cassette () at cva.c:189
> > #8  0x41df9219 in gl_maybe_transform_vb () at vbxform.c:188
> > #9  0x41df92b9 in gl_flush_vb () at vbxform.c:188
> > #10 0x41cdab66 in gl_BlendFunc () at blend.c:212
> > #11 0x41cc6580 in glBlendFunc () at api1.c:1647
> > #12 0x412aa4e6 in UXMesaGLRenderDevice::DrawComplexSurface ()
> >    from /.2/ut/System/XMesaGLDrv.so
> > #13 0x40ade4a4 in URender::DrawFrame () from /.2/ut/System/Render.so
> > #14 0x40adff3f in URender::DrawWorld () from /.2/ut/System/Render.so
> > #15 0xc8 in ?? ()
> 
> I did a bit more research and found that I am getting garbage in
> VB->Win.data[vMid][0]:
> 
> (gdb) p VB->Win.data[vMid][0]
> $7 = -NaN(0x400000)
> 

Aha, I think that I have found it.
With sanity-check.diff applied I get the following output:
general_clip.h:viewclip_polygon_4: Sanity check failed at line 109:
general_clip.h:viewclip_polygon_4: Y(out) is 394.594452, Y(in) is 81.216568, dy is 
313.377869
general_clip.h:viewclip_polygon_4: W(out) is 394.594421, W(in) is 81.216568, dw is 
313.377869
general_clip.h:viewclip_polygon_4: Y(in)-W(in) is 0.000000, dw-dy is 0.000000
general_clip.h:viewclip_polygon_4: t is nan,neww is nan

And the attached file general-clip.diff seems to fix the problem.


regards
Andreas Ehliar
Index: general_clip.h
===================================================================
RCS file: /cvs/mesa3d/Mesa/src/general_clip.h,v
retrieving revision 1.2
diff -u -r1.2 general_clip.h
--- general_clip.h      1999/11/09 17:00:25     1.2
+++ general_clip.h      2000/01/17 01:51:56
@@ -44,6 +44,11 @@
        neww = W(in) + t * dw;                          \
        X(new) = neww;                                  \
        Y(new) = Y(in) + t * (Y(out) - Y(in));          \
+        if(t!=t){printf(__FILE__ ":" __FUNCTION__ ": Sanity check failed at line 
+%d:\n",__LINE__);\
+                 printf(__FILE__ ":" __FUNCTION__ ": X(out) is %f, X(in) is %f, dx is 
+%f\n",X(out),X(in),dx);\
+                 printf(__FILE__ ":" __FUNCTION__ ": W(out) is %f, W(in) is %f, dw is 
+%f\n",W(out),W(in),dw);\
+                 printf(__FILE__ ":" __FUNCTION__ ": X(in)-W(in) is %f, dw-dx is 
+%f\n",X(in)-W(in),dw-dx);\
+                 printf(__FILE__ ":" __FUNCTION__ ": t is %f,neww is 
+%f\n",t,neww);abort();}\
        if (SIZE>=3) coord[new][2] = Z(in) + t * (Z(out) - Z(in));              \
        if (SIZE==4) coord[new][3] = neww;
 
@@ -66,6 +71,11 @@
        neww = W(in) + t * dw;                          \
         X(new) = -neww;                                        \
         Y(new) = Y(in) + t * (Y(out) - Y(in));         \
+        if(t!=t){printf(__FILE__ ":" __FUNCTION__ ": Sanity check failed at line 
+%d:\n",__LINE__);\
+                 printf(__FILE__ ":" __FUNCTION__ ": X(out) is %f, X(in) is %f, dx is 
+%f\n",X(out),X(in),dx);\
+                 printf(__FILE__ ":" __FUNCTION__ ": W(out) is %f, W(in) is %f, dw is 
+%f\n",W(out),W(in),dw);\
+                 printf(__FILE__ ":" __FUNCTION__ ": X(in)+W(in) is %f, dw+dx is 
+%f\n",X(in)+W(in),dw+dx);\
+                 printf(__FILE__ ":" __FUNCTION__ ": t is %f,neww is 
+%f\n",t,neww);abort();}\
         if (SIZE>=3) coord[new][2] = Z(in) + t * (Z(out) - Z(in));             \
         if (SIZE==4) coord[new][3] = neww;
 
@@ -84,10 +94,15 @@
 #define COMPUTE_INTERSECTION( in, out, new )           \
         dy = Y(out)-Y(in);                             \
         dw = W(out)-W(in);                             \
-        t = (Y(in)-W(in)) / (dw-dy);                   \
+       t = (Y(in)-W(in)) / (dw-dy);                    \
        neww = W(in) + t * dw;                          \
         X(new) = X(in) + t * (X(out) - X(in));         \
         Y(new) = neww;                                 \
+        if(t!=t){printf(__FILE__ ":" __FUNCTION__ ": Sanity check failed at line 
+%d:\n",__LINE__);\
+                 printf(__FILE__ ":" __FUNCTION__ ": Y(out) is %f, Y(in) is %f, dy is 
+%f\n",Y(out),Y(in),dy);\
+                 printf(__FILE__ ":" __FUNCTION__ ": W(out) is %f, W(in) is %f, dw is 
+%f\n",W(out),W(in),dw);\
+                 printf(__FILE__ ":" __FUNCTION__ ": Y(in)-W(in) is %f, dw-dy is 
+%f\n",Y(in)-W(in),dw-dy);\
+                 printf(__FILE__ ":" __FUNCTION__ ": t is %f,neww is 
+%f\n",t,neww);abort();}\
         if (SIZE>=3) coord[new][2] = Z(in) + t * (Z(out) - Z(in));             \
         if (SIZE==4) coord[new][3] = neww;
 
@@ -106,10 +121,15 @@
 #define COMPUTE_INTERSECTION( in, out, new )           \
         dy = Y(out)-Y(in);                             \
         dw = W(out)-W(in);                             \
-        t = -(Y(in)+W(in)) / (dw+dy);                  \
+       t = -(Y(in)+W(in)) / (dw+dy);                   \
        neww = W(in) + t * dw;                          \
         X(new) = X(in) + t * (X(out) - X(in));         \
         Y(new) = -neww;                                        \
+        if(t!=t){printf(__FILE__ ":" __FUNCTION__ ": Sanity check failed at line 
+%d:\n",__LINE__);\
+                 printf(__FILE__ ":" __FUNCTION__ ": Y(out) is %f, Y(in) is %f, dy is 
+%f\n",Y(out),Y(in),dy);\
+                 printf(__FILE__ ":" __FUNCTION__ ": W(out) is %f, W(in) is %f, dw is 
+%f\n",W(out),W(in),dw);\
+                 printf(__FILE__ ":" __FUNCTION__ ": Y(in)+W(in) is %f, dw+dy is 
+%f\n",Y(in)+W(in),dw+dy);\
+                 printf(__FILE__ ":" __FUNCTION__ ": t is %f,neww is 
+%f\n",t,neww);abort();}\
         if (SIZE>=3) coord[new][2] = Z(in) + t * (Z(out) - Z(in));             \
         if (SIZE==4) coord[new][3] = neww;
 
@@ -129,10 +149,15 @@
 #define COMPUTE_INTERSECTION( in, out, new )           \
           dz = Z(out)-Z(in);                           \
           dw = W(out)-W(in);                           \
-          t = (Z(in)-W(in)) / (dw-dz);                 \
+          t = (Z(in)-W(in)) / (dw-dz);         \
           neww = W(in) + t * dw;                       \
           X(new) = X(in) + t * (X(out) - X(in));       \
           Y(new) = Y(in) + t * (Y(out) - Y(in));       \
+        if(t!=t){printf(__FILE__ ":" __FUNCTION__ ": Sanity check failed at line 
+%d:\n",__LINE__);\
+                 printf(__FILE__ ":" __FUNCTION__ ": Z(out) is %f, Z(in) is %f, dz is 
+%f\n",Z(out),Z(in),dz);\
+                 printf(__FILE__ ":" __FUNCTION__ ": W(out) is %f, W(in) is %f, dw is 
+%f\n",W(out),W(in),dw);\
+                 printf(__FILE__ ":" __FUNCTION__ ": Z(in)-W(in) is %f, dw-dz is 
+%f\n",Z(in)-W(in),dw-dz);\
+                 printf(__FILE__ ":" __FUNCTION__ ": t is %f,neww is 
+%f\n",t,neww);abort();}\
           coord[new][2] = neww;                                \
           if (SIZE==4) coord[new][3] = neww;
 
@@ -153,10 +178,15 @@
 #define COMPUTE_INTERSECTION( in, out, new )   \
         dz = Z(out)-Z(in);                     \
         dw = W(out)-W(in);                     \
-        t = -(Z(in)+W(in)) / (dw+dz);          \
+       t = -(Z(in)+W(in)) / (dw+dz);           \
        neww = W(in) + t * dw;                  \
         X(new) = X(in) + t * (X(out) - X(in)); \
         Y(new) = Y(in) + t * (Y(out) - Y(in)); \
+        if(t!=t){printf(__FILE__ ":" __FUNCTION__ ": Sanity check failed at line 
+%d:\n",__LINE__);\
+                 printf(__FILE__ ":" __FUNCTION__ ": Z(out) is %f, Z(in) is %f, dy is 
+%f\n",Z(out),Z(in),dz);\
+                 printf(__FILE__ ":" __FUNCTION__ ": W(out) is %f, W(in) is %f, dw is 
+%f\n",W(out),W(in),dw);\
+                 printf(__FILE__ ":" __FUNCTION__ ": Z(in)+W(in) is %f, dw+dz is 
+%f\n",Z(in)+W(in),dw+dz);\
+                 printf(__FILE__ ":" __FUNCTION__ ": t is %f,neww is 
+%f\n",t,neww);abort();}\
         coord[new][2] = -neww;                         \
         if (SIZE==4) coord[new][3] = neww; 
 
@@ -168,5 +198,11 @@
 #undef PLANE
 #undef COMPUTE_INTERSECTION
 #undef GENERAL_CLIP
+
+
+
+
+
+
 
 
Index: general_clip.h
===================================================================
RCS file: /cvs/mesa3d/Mesa/src/general_clip.h,v
retrieving revision 1.2
diff -u -r1.2 general_clip.h
--- general_clip.h      1999/11/09 17:00:25     1.2
+++ general_clip.h      2000/01/17 01:54:59
@@ -40,7 +40,8 @@
 #define COMPUTE_INTERSECTION( in, out, new )           \
         dx = X(out)-X(in);                             \
         dw = W(out)-W(in);                             \
-        t = (X(in)-W(in)) / (dw-dx);                   \
+        if(X(in)-W(in) == dw - dx){t=1;}               \
+        else{t = (X(in)-W(in)) / (dw-dx);}             \
        neww = W(in) + t * dw;                          \
        X(new) = neww;                                  \
        Y(new) = Y(in) + t * (Y(out) - Y(in));          \
@@ -62,7 +63,8 @@
 #define COMPUTE_INTERSECTION( in, out, new )           \
         dx = X(out)-X(in);                             \
         dw = W(out)-W(in);                             \
-        t = -(X(in)+W(in)) / (dw+dx);                  \
+        if(X(in)+W(in) == dw+dx){t=1;}                 \
+        else{t = -(X(in)+W(in)) / (dw+dx);}            \
        neww = W(in) + t * dw;                          \
         X(new) = -neww;                                        \
         Y(new) = Y(in) + t * (Y(out) - Y(in));         \
@@ -84,7 +86,8 @@
 #define COMPUTE_INTERSECTION( in, out, new )           \
         dy = Y(out)-Y(in);                             \
         dw = W(out)-W(in);                             \
-        t = (Y(in)-W(in)) / (dw-dy);                   \
+        if(Y(in)-W(in) == dw-dy){t=1;}                 \
+       else{t = (Y(in)-W(in)) / (dw-dy);}              \
        neww = W(in) + t * dw;                          \
         X(new) = X(in) + t * (X(out) - X(in));         \
         Y(new) = neww;                                 \
@@ -106,7 +109,8 @@
 #define COMPUTE_INTERSECTION( in, out, new )           \
         dy = Y(out)-Y(in);                             \
         dw = W(out)-W(in);                             \
-        t = -(Y(in)+W(in)) / (dw+dy);                  \
+       if(Y(in)+W(in)==dw+dy){t=1;}                    \
+       else{t = -(Y(in)+W(in)) / (dw+dy);}             \
        neww = W(in) + t * dw;                          \
         X(new) = X(in) + t * (X(out) - X(in));         \
         Y(new) = -neww;                                        \
@@ -129,7 +133,8 @@
 #define COMPUTE_INTERSECTION( in, out, new )           \
           dz = Z(out)-Z(in);                           \
           dw = W(out)-W(in);                           \
-          t = (Z(in)-W(in)) / (dw-dz);                 \
+          if(Z(in)-W(in) == dw-dx){t=1;}               \
+          else{t = (Z(in)-W(in)) / (dw-dz);}           \
           neww = W(in) + t * dw;                       \
           X(new) = X(in) + t * (X(out) - X(in));       \
           Y(new) = Y(in) + t * (Y(out) - Y(in));       \
@@ -153,7 +158,8 @@
 #define COMPUTE_INTERSECTION( in, out, new )   \
         dz = Z(out)-Z(in);                     \
         dw = W(out)-W(in);                     \
-        t = -(Z(in)+W(in)) / (dw+dz);          \
+        if(Z(in)+W(in) == dw+dz){t=1;}         \
+       else{t = -(Z(in)+W(in)) / (dw+dz);}     \
        neww = W(in) + t * dw;                  \
         X(new) = X(in) + t * (X(out) - X(in)); \
         Y(new) = Y(in) + t * (Y(out) - Y(in)); \
@@ -168,5 +174,11 @@
 #undef PLANE
 #undef COMPUTE_INTERSECTION
 #undef GENERAL_CLIP
+
+
+
+
+
+
 
 

Reply via email to