Hi James,

It looks to be related to Alexander Sinditskiy's submission that add
texture storage support.  The function that is failing is:

GLenum assumeSizedInternalFormat(GLint internalFormat, GLenum type)
{
    const size_t formatsCount = sizeof(sizedInternalFormats) /
sizeof(sizedInternalFormats[0]);

    size_t i = formatsCount;
    while(i >= 0)
    {
        if(internalFormat == sizedInternalFormats[i].internalFormat && type
== sizedInternalFormats[i].type)
            return sizedInternalFormats[i].sizedInternalFormat;
        --i;
    }

    return 0;
}

I really don't have enough information from your stack trace to know what
the problem would be, but from a code review it looks like the i value
initialized to a value over the end of the sizedInternalFormats array.  I
don't know why Alexander didn't just iterate forwards form i=0; and use a
for loop.

My inclination is to the change the i start value to 0 and use a for loop
as it'll make the code both more compact and readable.  If we are to stick
with the original code then it would seem like replacing the i
initialization with:

size_t i = formatsCount-1 or move the --i to in front of the if statement.
Either way it's a bit kludgey.  I regret not reviewing the code a bit more
closely now and getting a better explanation of the motivation of each
part.

Robert.




On 13 November 2014 20:48, James Turner <[email protected]> wrote:

> Hi,
>
> I'm getting a crash with latest trunk OSG (having not previously updated
> for some time, eg six months or more).
>
> (lldb) bt
> * thread #1: tid = 0x24881d, 0x00000001040df3c4
> libosg.115.dylib`osg::Texture::applyTexImage2D_load(osg::State&, unsigned
> int, osg::Image const*, int, int, int) const [inlined]
> osg::assumeSizedInternalFormat(internalFormat=6406, type=5121) + 4 at
> Texture.cpp:225, queue = 'com.apple.main-thread', stop reason =
> EXC_BAD_ACCESS (code=1, address=0xfffffffc)
>   * frame #0: 0x00000001040df3c4
> libosg.115.dylib`osg::Texture::applyTexImage2D_load(osg::State&, unsigned
> int, osg::Image const*, int, int, int) const [inlined]
> osg::assumeSizedInternalFormat(internalFormat=6406, type=5121) + 4 at
> Texture.cpp:225
>     frame #1: 0x00000001040df3c0
> libosg.115.dylib`osg::Texture::applyTexImage2D_load(this=0x0000000104670dc0,
> state=0x0000000104810800, target=3553, image=0x00006180003b2980,
> inwidth=64, inheight=64, numMipmapLevels=8) const + 3360 at Texture.cpp:2284
>     frame #2: 0x00000001040d397f
> libosg.115.dylib`osg::Texture2D::apply(this=0x0000000104670dc0,
> state=0x0000000104810800) const + 1695 at Texture2D.cpp:270
>     frame #3: 0x00000001040b49e7
> libosg.115.dylib`osg::State::applyAttributeListOnTexUnit(unsigned int,
>
>
> The internalFormat and type values correspond to GL_ALPHA and
> GL_UNSIGNED_BYTE. This case isn't covered by the sizedInternalFormats
> array, so one would expect the code to have the i counter reach 0, and the
> function return 0.
>
> This is on clang, Xcode 6.1. Crash is reproducible in all kinds of builds
> (release, debug, rel-with-deb-info) that I tried so far.
>
> Given this code has been in OSG since June according to the blame/log, I
> guess most people are not experiencing the issue, but I thought it best to
> ask here before spending time adding debug logic to the code.
>
> Kind regards,
> James
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to