OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

osg::Text::setBackdropType crash with a single character string


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
Carlo Lanzotti - DynaD...
Guest





PostPosted: Wed Sep 20, 2017 2:40 pm    Post subject:
osg::Text::setBackdropType crash with a single character string
Reply with quote

Hi all,

when using osgText::Text::setBackdropType() with any shadow flag and a
string with only one character a crash occur ("vector subscript out of
range" exception are raised in debug mode, track
Text::computeAverageGlyphWidthAndHeight()):

osgText::Text *text = new osgText::Text;
text->setBackdropType(osgText::Text::DROP_SHADOW_BOTTOM_RIGHT);
text->setText("X");

OSG Version: 3.4.1 64 bit, Visual Studio 2017, Windows 10,

Best Regards

--
Carlo Lanzotti

DynaDream - Dynamic Laboratory

http://www.dynadream.com



------------------
Post generated by Mail2Forum
Back to top
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12148

PostPosted: Wed Sep 20, 2017 3:23 pm    Post subject:
osg::Text::setBackdropType crash with a single character string
Reply with quote

Hi Carlo,

On 20 September 2017 at 15:40, Carlo Lanzotti - DynaDream < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
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.



 


 

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Carlo Lanzotti
Guest





PostPosted: Wed Sep 20, 2017 4:35 pm    Post subject:
osg::Text::setBackdropType crash with a single character string
Reply with quote

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 < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> ha scritto:


Quote:
Hi Carlo,

On 20 September 2017 at 15:40, Carlo Lanzotti - DynaDream < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
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
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



------------------
Post generated by Mail2Forum
Back to top
Carlo Lanzotti - DynaD...
Guest





PostPosted: Tue Sep 26, 2017 9:37 am    Post subject:
osg::Text::setBackdropType crash with a single character string
Reply with quote

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:

Quote:
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 < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> ha scritto:


Quote:
Hi Carlo,

On 20 September 2017 at 15:40, Carlo Lanzotti - DynaDream < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
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
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




Quote:
_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Quote:
--
Carlo Lanzotti

DynaDream - Dynamic Laboratory

http://www.dynadream.com


------------------
Post generated by Mail2Forum
Back to top
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12148

PostPosted: Tue Sep 26, 2017 11:31 am    Post subject:
osg::Text::setBackdropType crash with a single character string
Reply with quote

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 < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
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:



Quote:
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 < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> ha scritto:


Quote:
Hi Carlo,

On 20 September 2017 at 15:40, Carlo Lanzotti - DynaDream < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
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
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




Quote:
_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




Quote:
--
Carlo Lanzotti

DynaDream - Dynamic Laboratory

http://www.dynadream.com


_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Carlo Lanzotti - DynaD...
Guest





PostPosted: Tue Sep 26, 2017 2:42 pm    Post subject:
osg::Text::setBackdropType crash with a single character string
Reply with quote

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:

Quote:
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 < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
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:



Quote:
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 < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> ha scritto:


Quote:
Hi Carlo,

On 20 September 2017 at 15:40, Carlo Lanzotti - DynaDream < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
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
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




Quote:
_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




Quote:
--
Carlo Lanzotti

DynaDream - Dynamic Laboratory

http://www.dynadream.com


_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org






Quote:
_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Quote:
--
Carlo Lanzotti

DynaDream - Dynamic Laboratory

http://www.dynadream.com


------------------
Post generated by Mail2Forum
Back to top
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12148

PostPosted: Tue Sep 26, 2017 3:44 pm    Post subject:
osg::Text::setBackdropType crash with a single character string
Reply with quote

Hi Carlo,

On 26 September 2017 at 15:41, Carlo Lanzotti - DynaDream < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
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...).




For the osgText implementation there isn't any special handling of "special characters", all characters glyphs are treated as textured quads, so this finding is to be expected.


Robert.

 

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12148

PostPosted: Thu Oct 05, 2017 5:17 pm    Post subject:
osg::Text::setBackdropType crash with a single character string
Reply with quote

Hi Carlo,


I have just tried to reproduce the crash using master, 3.4 branch, 3.4.1 and 3.4.0 and haven't yet been able to reproduce any errors or odd values when using a single character setText with the backdrop setting you suggested.  The line number you reference doesn't match up with anything that seems to match what I am seeing for the code you referenced.  This leaves me a bit confused as to what version of the OSG you are using, and exactly how you were able to produce the issue.


Could you post a small example that illustrates the problem and double check the version of the OSG you are using and the files/line numbers you've been modifying, without this I don't have anything to go on, I've tried really hard to  track things and can't do anything more at this point without more direct guidance.


Robert.

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Compute line numbers for Glyphs in Te... Ferran Pallarès General 2 Wed Oct 24, 2018 5:58 pm View latest post
No new posts osgText 3.6.3 crash Trajce Nikolov NICK General 2 Wed Sep 12, 2018 12:25 pm View latest post
No new posts Crash when using LineSegmentIntersector sbrkopac General 5 Thu Aug 02, 2018 10:03 pm View latest post
No new posts [Crash issue] no error info even set ... pwang General 1 Sun Jul 29, 2018 1:20 pm View latest post
No new posts [Crash issue] How to add&remove d... pwang General 2 Thu Jul 26, 2018 10:10 am View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP