[osg-users] osg::Text::setBackdropType crash with a single character string

Carlo Lanzotti - DynaDream clanzotti at dynadream.com
Tue Sep 26 07:41:41 PDT 2017


Hi Robert,

thank you for the more compact workaround, better than my slow module 
solution.

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...).

Best Regards,

Carlo Lanzotti

Il 26/09/2017 13:30, Robert Osfield ha scritto:
> Hi Carlo,
>
> I haven't had a chance to look at the issue yet.  Glad you've found a 
> workaround.
>
> 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.
>
> 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.
>
> The code that is crashing though, the offending four loop:
>
>    for (i = 0; i < _coords->size(); i += 4)
>
> Could probably be written:
>
>    for (i = 0; i+3 < _coords->size(); i += 4)
>
> This should work and be a bit simpler than your workaround.
>
> Cheers,
> Robert.
>
>
> On 26 September 2017 at 10:36, Carlo Lanzotti - DynaDream 
> <clanzotti at dynadream.com <mailto:clanzotti at dynadream.com>> wrote:
>
>     Hi all,
>
>     We had to temporarly fix this problem as we have to go in
>     production. The problem is in
>     osg::Text::computeAverageGlyphWidthAndHeight() line 602:
>
>         for (i = 0; i < _coords->size(); i += 4)
>
>     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:
>
>         unsigned int sz = _coords->size() - (_coords->size() % 4);
>
>         for (i = 0; i < sz; i += 4)
>         {
>             ...
>         }
>
>     Of course this need to be fixed in some other way as it avoid the
>     crash but probably do not give the correct result.
>
>     Best Regards,
>
>     Carlo Lanzotti
>
>
>     Il 20/09/2017 18:35, Carlo Lanzotti ha scritto:
>>     Hi Robert,
>>
>>     I’ve not tried other OS combinations yet but I made that simple
>>     test in the osgtext sample too and the crash happens.
>>
>>     I’ll see if I can reproduce it on OSX.
>>
>>     Thank you.
>>
>>     Carlo Lanzotti
>>
>>     Il giorno 20 set 2017, alle ore 17:23, Robert Osfield
>>     <robert.osfield at gmail.com <mailto:robert.osfield at gmail.com>> ha
>>     scritto:
>>
>>>     Hi Carlo,
>>>
>>>     On 20 September 2017 at 15:40, Carlo Lanzotti - DynaDream
>>>     <clanzotti at dynadream.com <mailto:clanzotti at dynadream.com>> wrote:
>>>
>>>         OSG Version: 3.4.1 64 bit, Visual Studio 2017, Windows 10,
>>>
>>>
>>>     Have you tried any other OSG+OS combinations? Is so they exhibit
>>>     the problem?
>>>
>>>     FYI, there are so major internal changes to osgText since 3.4.x
>>>     so there is changes that OSG master will address this issue.
>>>
>>>     Cheers,
>>>     Robert.
>>>
>>>
>>>
>>>     _______________________________________________
>>>     osg-users mailing list
>>>     osg-users at lists.openscenegraph.org
>>>     <mailto:osg-users at lists.openscenegraph.org>
>>>     http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>>     <http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org>
>>
>>
>>     _______________________________________________
>>     osg-users mailing list
>>     osg-users at lists.openscenegraph.org
>>     <mailto:osg-users at lists.openscenegraph.org>
>>     http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>     <http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org>
>
>
>     -- 
>     Carlo Lanzotti
>
>     DynaDream - Dynamic Laboratory
>
>     http://www.dynadream.com
>
>
>     _______________________________________________
>     osg-users mailing list
>     osg-users at lists.openscenegraph.org
>     <mailto:osg-users at lists.openscenegraph.org>
>     http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>     <http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


-- 
Carlo Lanzotti

DynaDream - Dynamic Laboratory

http://www.dynadream.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20170926/fdd15495/attachment.htm>


More information about the osg-users mailing list