<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Hi Robert,<br>
      <br>
      thank you for the more compact workaround, better than my slow
      module solution. <br>
      <br>
      P.S. If it can be of help while debugging, I found that the non
      module 4 size show up even when using special characters (like . ,
      ; etc...).<br>
      <br>
      Best Regards,<br>
      <br>
      Carlo Lanzotti<br>
      <br>
      Il 26/09/2017 13:30, Robert Osfield ha scritto:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAFN7Y+V0qR-UraqLwR_9Bwsajd83xAhMn7gmLAKELa_sXeDOug@mail.gmail.com">
      <div dir="ltr">
        <div>Hi Carlo,<br>
        </div>
        <div><br>
        </div>
        <div>I haven't had a chance to look at the issue yet.  Glad
          you've found a workaround.  <br>
        </div>
        <div><br>
        </div>
        <div>I have just had a quick look at the text_improvements
          branch of master than I'm currently working on and it's
          Text::computeAverageGlyphWidthAndHeight() has the same code
          still in place so looks likely to suffer from the same bug.  
          The code assumes that the number of _coords is a multiple of
          four, outwardly this would look like a reasonable assumption
          given the way that osgText used quads for rendering glyphs. <br>
        </div>
        <div><br>
        </div>
        <div>From a quick code review I haven't yet spotted why the
          number _coords isn't always a multiple of 4.  I will need to
          add some debug output to track when the number multiple of 4
          case is happening, whether this itself is a bug or whether
          it's just a corner case.<br>
        </div>
        <div><br>
        </div>
        <div>The code that is crashing though, the offending four loop:<br>
        </div>
        <div><br>
        </div>
        <div>   for (i = 0; i < _coords->size(); i += 4)</div>
        <div><br>
        </div>
        <div>Could probably be written:</div>
        <div><br>
        </div>
        <div>
          <div>   for (i = 0; i+3 < _coords->size(); i += 4)</div>
          <div><br>
          </div>
          <div>This should work and be a bit simpler than your
            workaround.<br>
          </div>
        </div>
        <div><br>
        </div>
        <div>Cheers,<br>
        </div>
        <div>Robert.<br>
        </div>
        <div><br>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On 26 September 2017 at 10:36, Carlo
          Lanzotti - DynaDream <span dir="ltr"><<a
              href="mailto:clanzotti@dynadream.com" target="_blank"
              moz-do-not-send="true">clanzotti@dynadream.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div text="#000000" bgcolor="#FFFFFF">
              <div class="m_121885268941884952moz-cite-prefix">Hi all,<br>
                <br>
                We had to temporarly fix this problem as we have to go
                in production. The problem is in osg::Text::<wbr>computeAverageGlyphWidthAndHei<wbr>ght()
                line 602:<br>
                <br>
                    for (i = 0; i < _coords->size(); i += 4)<br>
                <br>
                sometime it happens that _coords->size() is not
                multiple of 4 leading to an out of range access to the
                _coords array. To avoid the crash I fixed this way:<br>
                <br>
                    unsigned int sz = _coords->size() -
                (_coords->size() % 4);<br>
                <br>
                    for (i = 0; i < sz; i += 4)<br>
                    {<br>
                        ...<br>
                    }    <br>
                <br>
                Of course this need to be fixed in some other way as it
                avoid the crash but probably do not give the correct
                result.<br>
                <br>
                Best Regards,<br>
                <br>
                Carlo Lanzotti
                <div>
                  <div class="h5"><br>
                    <br>
                    Il 20/09/2017 18:35, Carlo Lanzotti ha scritto:<br>
                  </div>
                </div>
              </div>
              <div>
                <div class="h5">
                  <blockquote type="cite"> Hi Robert,
                    <div><br>
                    </div>
                    <div>I’ve not tried other OS combinations yet but I
                      made that simple test in the osgtext sample too
                      and the crash happens.</div>
                    <div><br>
                    </div>
                    <div>I’ll see if I can reproduce it on OSX.<br>
                      <br>
                      Thank you.</div>
                    <div><br>
                      <div id="m_121885268941884952AppleMailSignature">Carlo
                        Lanzotti</div>
                      <div><br>
                        Il giorno 20 set 2017, alle ore 17:23, Robert
                        Osfield <<a
                          href="mailto:robert.osfield@gmail.com"
                          target="_blank" moz-do-not-send="true">robert.osfield@gmail.com</a>>
                        ha scritto:<br>
                        <br>
                      </div>
                      <blockquote type="cite">
                        <div>
                          <div dir="ltr">Hi Carlo,<br>
                            <div class="gmail_extra"><br>
                              <div class="gmail_quote">On 20 September
                                2017 at 15:40, Carlo Lanzotti -
                                DynaDream <span dir="ltr"><<a
                                    href="mailto:clanzotti@dynadream.com"
                                    target="_blank"
                                    moz-do-not-send="true">clanzotti@dynadream.com</a>></span>
                                wrote:<br>
                                <blockquote class="gmail_quote"
                                  style="margin:0 0 0
                                  .8ex;border-left:1px #ccc
                                  solid;padding-left:1ex">OSG Version:
                                  3.4.1 64 bit, Visual Studio 2017,
                                  Windows 10,<br>
                                </blockquote>
                                <div><br>
                                </div>
                                <div>Have you tried any other OSG+OS
                                  combinations? Is so they exhibit the
                                  problem?</div>
                                <div><br>
                                </div>
                                <div>FYI, there are so major internal
                                  changes to osgText since 3.4.x so
                                  there is changes that OSG master will
                                  address this issue.</div>
                                <div><br>
                                </div>
                                <div>Cheers,</div>
                                <div>Robert.<br>
                                </div>
                                <div><br>
                                </div>
                                <div> </div>
                                <div><br>
                                </div>
                                <div> </div>
                              </div>
                              <br>
                            </div>
                          </div>
                        </div>
                      </blockquote>
                      <blockquote type="cite">
                        <div><span>______________________________<wbr>_________________</span><br>
                          <span>osg-users mailing list</span><br>
                          <span><a
                              href="mailto:osg-users@lists.openscenegraph.org"
                              target="_blank" moz-do-not-send="true">osg-users@lists.<wbr>openscenegraph.org</a></span><br>
                          <span><a
href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org"
                              target="_blank" moz-do-not-send="true">http://lists.openscenegraph.<wbr>org/listinfo.cgi/osg-users-<wbr>openscenegraph.org</a></span><br>
                        </div>
                      </blockquote>
                    </div>
                    <br>
                    <fieldset
                      class="m_121885268941884952mimeAttachmentHeader"></fieldset>
                    <br>
                    <pre>______________________________<wbr>_________________
osg-users mailing list
<a class="m_121885268941884952moz-txt-link-abbreviated" href="mailto:osg-users@lists.openscenegraph.org" target="_blank" moz-do-not-send="true">osg-users@lists.<wbr>openscenegraph.org</a>
<a class="m_121885268941884952moz-txt-link-freetext" href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" target="_blank" moz-do-not-send="true">http://lists.openscenegraph.<wbr>org/listinfo.cgi/osg-users-<wbr>openscenegraph.org</a>
</pre>
                  </blockquote>
                  <p><br>
                  </p>
                </div>
              </div>
              <span class="">
                <pre class="m_121885268941884952moz-signature" cols="72">-- 
Carlo Lanzotti

DynaDream - Dynamic Laboratory

<a class="m_121885268941884952moz-txt-link-freetext" href="http://www.dynadream.com" target="_blank" moz-do-not-send="true">http://www.dynadream.com</a></pre>
              </span></div>
            <br>
            ______________________________<wbr>_________________<br>
            osg-users mailing list<br>
            <a href="mailto:osg-users@lists.openscenegraph.org"
              moz-do-not-send="true">osg-users@lists.<wbr>openscenegraph.org</a><br>
            <a
href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org"
              rel="noreferrer" target="_blank" moz-do-not-send="true">http://lists.openscenegraph.<wbr>org/listinfo.cgi/osg-users-<wbr>openscenegraph.org</a><br>
            <br>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
osg-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a>
<a class="moz-txt-link-freetext" href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a>
</pre>
    </blockquote>
    <p><br>
    </p>
    <pre class="moz-signature" cols="72">-- 
Carlo Lanzotti

DynaDream - Dynamic Laboratory

<a class="moz-txt-link-freetext" href="http://www.dynadream.com">http://www.dynadream.com</a></pre>
  </body>
</html>