'vector subscription out of range' assertion

View: New views
3 Messages — Rating Filter:   Alert me  

'vector subscription out of range' assertion

by torokze :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

The attached wrl file (made with 3DS max 2009) causes a 'vector subscription
out of range'  assertion
in viewer.cpp@line:3082

Zolee


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
openvrml-develop mailing list
openvrml-develop@...
https://lists.sourceforge.net/lists/listinfo/openvrml-develop

room.WRL (217K) Download Attachment

Re: 'vector subscription out of range' assertion

by Braden McDaniel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Zoltán Török wrote:
> Hi,
>
> The attached wrl file (made with 3DS max 2009) causes a 'vector subscription
> out of range'  assertion
> in viewer.cpp@line:3082

Thanks. I've reproduced this. I'll have a look at fixing it tonight.

--
Braden McDaniel                      e-mail: <braden@...>
<http://endoframe.com>               Jabber: <braden@...>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
openvrml-develop mailing list
openvrml-develop@...
https://lists.sourceforge.net/lists/listinfo/openvrml-develop

Re: 'vector subscription out of range' assertion

by Braden McDaniel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, 2008-07-24 at 18:53 +0200, Zoltán Török wrote:
> Hi,
>
> The attached wrl file (made with 3DS max 2009) causes a 'vector subscription
> out of range'  assertion
> in viewer.cpp@line:3082

I've attached a patch that should address this (and other) problems.

While the crash you noted was squarely the fault of OpenVRML, fixing it
led to a crash due to some invalid data in room.wrl. The node
WALL02-FACES uses 24 as a coordIndex; but there are only 24 coordinates.
(Coordinates are indexed starting at 0; so 24 is out of range.)

Nonetheless, crashing is not an appropriate response to invalid input;
so this, too, has been fixed. This patch makes OpenVRML skip invalid
coordinate indices (along with any subsequent indices in the same
polygon).

This patch was created against the trunk; but I suspect it will apply
cleanly to 0.17.6.

--
Braden McDaniel                           e-mail: <braden@...>
<http://endoframe.com>                    Jabber: <braden@...>


[per-vertex.patch]

Index: src/libopenvrml-gl/openvrml/gl/viewer.cpp
===================================================================
--- src/libopenvrml-gl/openvrml/gl/viewer.cpp (revision 3494)
+++ src/libopenvrml-gl/openvrml/gl/viewer.cpp (working copy)
@@ -2939,7 +2939,14 @@
         for (vector<openvrml::int32>::size_type i = 0;
              i < coord_index.size();
              ++i) {
-            if (coord_index[i] != -1) {
+            using openvrml::int32;
+            if (!(coord_index[i] < int32(vertices.size()))) {
+                //
+                // We've encountered an invalid coordinate index.  Advance to
+                // the next polygon.
+                //
+                while (coord_index[i + 1] != -1) { ++i; }
+            } else if (coord_index[i] != -1) {
                 gluTessVertex(&tessobj,
                               const_cast<GLdouble *>(
                                   vertices[coord_index[i]].coord),
@@ -3060,11 +3067,13 @@
                      ++i) {
                     vertices[i].color = &color[i];
                 }
-            } else {
+            } else if (color_index.size() == coord_index.size()) {
                 for (vector<int32>::size_type i = 0;
                      i < color_index.size();
                      ++i) {
-                    vertices[i].color = &color[color_index[i]];
+                    if (color_index[i] < 0) { continue; }
+                    if (!(coord_index[i] < coord.size())) { continue; }
+                    vertices[coord_index[i]].color = &color[color_index[i]];
                 }
             }
         }
@@ -3075,11 +3084,13 @@
                      ++i) {
                     vertices[i].normal = &normal[i];
                 }
-            } else {
+            } else if (normal_index.size() == coord_index.size()) {
                 for (vector<int32>::size_type i = 0;
                      i < normal_index.size();
                      ++i) {
-                    vertices[i].normal = &normal[normal_index[i]];
+                    if (normal_index[i] < 0) { continue; }
+                    if (!(coord_index[i] < coord.size())) { continue; }
+                    vertices[coord_index[i]].normal = &normal[normal_index[i]];
                 }
             }
         }
@@ -3094,6 +3105,7 @@
             for (vector<int32>::size_type i = 0;
                  i < tex_coord_index.size();
                  ++i) {
+                if (tex_coord_index[i] < 0) { continue; }
                 vertices[tex_coord_index[i]].tex_coord =
                     &tex_coord[tex_coord_index[i]];
             }


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
openvrml-develop mailing list
openvrml-develop@...
https://lists.sourceforge.net/lists/listinfo/openvrml-develop
LightInTheBox - Buy quality products at wholesale price