[no bug] Bug in COGLES2MaterialRenderer

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
porcus
Posts: 149
Joined: Sun May 27, 2007 6:24 pm
Location: Germany

[no bug] Bug in COGLES2MaterialRenderer

Post by porcus »

Hi,

there's a bug in COGLES2MaterialRenderer.cpp in both implementations of setPixelShaderConstant:

original code:

Code: Select all

if(index < 0 || UniformInfo[index].location < 0)
return false;
If index is <0 it will crash because of UniformInfo[index].

Please replace it (both times) with (or similar):

Code: Select all

    if(index < 0 || index >= (int)UniformInfo.size())
        return false;
 
    if(UniformInfo[index].location < 0)
        return false;
greetings
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Bug in COGLES2MaterialRenderer

Post by Nadro »

Thanks, I'll fix that.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Bug in COGLES2MaterialRenderer

Post by Nadro »

There is no bug in the following condition:

Code: Select all

if(index < 0 || UniformInfo[index].location < 0)
It's related to short-circuit evaluation.

Sorry that at first I wrote that I'll fix that, but I didn't precisely check your post :oops:
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
AReichl
Posts: 270
Joined: Wed Jul 13, 2011 2:34 pm

Re: [no bug] Bug in COGLES2MaterialRenderer

Post by AReichl »

- If index is <0 it will crash because of UniformInfo[index].
porcus - do you THINK it will crash or HAS it crashed?

Nadro is right - with an OR if the first is "true" the rest can be skipped (Konjunction).
Same with an AND: if the first is "false" the rest can be skipped (Disjunction).

Nevertheless - "if( ... index >= (int)UniformInfo.size() )" maybe also should be checked
for safety. Only god or Nadro know.
porcus
Posts: 149
Joined: Sun May 27, 2007 6:24 pm
Location: Germany

Re: [no bug] Bug in COGLES2MaterialRenderer

Post by porcus »

It has crashed because of this issue. I compiled it with GCC with debug symbols and identified the Problem with gdb. BTW: You can not know if every compiler with every settings does evaluate the disjunctions as you describe.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: [no bug] Bug in COGLES2MaterialRenderer

Post by hendu »

The C standard specifies that.
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: [no bug] Bug in COGLES2MaterialRenderer

Post by REDDemon »

[typo] seems COGLES2 Material Renderer is included twice here:

https://github.com/kexplo/irrlicht_ogl- ... nderer.cpp


@porcus, if the index passed is causing problems then it is set to a wrong value (and hence the crash is caused by the range guard on std::vector).
you have to track wich code is setting it to wrong value or just create a small program that reproduce that.
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
Post Reply