[osg-users] osg::Text::setBackdropType crash with a single character string
Robert Osfield
robert.osfield at gmail.com
Tue Sep 26 04:30:58 PDT 2017
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> 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> ha scritto:
>
> Hi Carlo,
>
> On 20 September 2017 at 15:40, Carlo Lanzotti - DynaDream <
> 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
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
>
> _______________________________________________
> osg-users mailing listosg-users at lists.openscenegraph.orghttp://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
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20170926/e446d20f/attachment.htm>
More information about the osg-users
mailing list