Nux

Invalid texture operations

Bug #1083149 reported by Eleni Maria Stea
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Nux
Fix Released
Medium
Unassigned
nux (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

** Critical Design Error!! **

In IOpenGLTexture2D.cpp the IOpenGLTexture2D destructor is called 2 times for some textures and the UnReference function can't find the already deleted object. We end up with a loop and we see nothing.

How to reproduce it:
First of all you need to compile without optimisations (otherwise you will see nothing):
export CXXFLAGS=-O0
export CFLAGS=-O0
make AM_DEFAULT_VERBOSITY=1

Then add this line at the beginning of the IOpenGLTexture2D::~IOpenGLTexture2D() destructor:
printf("IOpenGLTexture2D texture destructor: %p, function called: %s\n", this, __PRETTY_FUNCTION__);

Then go to the gputests and run the texture_copy_blur example.
You won't get an image and at some points you will get prints like that:

IOpenGLTexture2D texture destructor: 0xa917338, function called: virtual nux::IOpenGLTexture2D::~IOpenGLTexture2D()
IOpenGLTexture2D texture destructor: 0xa917338, function called: virtual nux::IOpenGLTexture2D::~IOpenGLTexture2D()

The exact same function (same pointer, same name, that is the IOpenGLTexture destructor) is called 2 times for some textures.

Now, if you change the case RTTEXTURE of the function void RenderingStats::UnRegister(IOpenGLResource *GraphicsObject) in RunTimeStats.cpp to look like this:

case RTTEXTURE:
      {
        int id = NUX_STATIC_CAST(IOpenGLBaseTexture *, GraphicsObject)->GetOpenGLID();
        if(!glIsTexture(id))
          printf("I am not a texture, I can't be deleted\n");

        _texture_2d_array.erase(std::remove(_texture_2d_array.begin(), _texture_2d_array.end(), id), _texture_2d_array.end());

        m_NumTex2D--;
        m_GPUSizeTex2D -= GetTextureSize(NUX_REINTERPRET_CAST(IOpenGLBaseTexture *, GraphicsObject));
        m_TotalGPUSize -= m_GPUSizeTex2D;
        break;
      }

and recompile (WITHOUT optimisations) you will get something like this:

IOpenGLTexture2D texture destructor: 0xa917338, function called: virtual nux::IOpenGLTexture2D::~IOpenGLTexture2D()
I am not a texture, I can't be deleted
IOpenGLTexture2D texture destructor: 0xa917338, function called: virtual nux::IOpenGLTexture2D::~IOpenGLTexture2D()
I am not a texture, I can't be deleted
IOpenGLTexture2D texture destructor: 0xa917338, function called: virtual nux::IOpenGLTexture2D::~IOpenGLTexture2D()
I am not a texture, I can't be deleted

Because an already deleted texture can't be deleted again.

If we add optimisations again, the texture_copy_blur example runs as usual but it still tries to delete the same texture multiple times.

comment #2: This happens because 2 different IOpenGLTexture2D objects have the same texture id.

Revision history for this message
Eleni Maria Stea (hikiko) wrote :

We might need to make changes on Nux design to solve this issue. In some cases we might end up with an infinite loop.

Changed in nux:
importance: Undecided → Critical
summary: - Critical design issue: The IOpenGLTexture2D destructor calls its own
- destructor
+ Critical design issue: The IOpenGLTexture2D destructor calls a function
+ that calls the destructor again (loop)
summary: - Critical design issue: The IOpenGLTexture2D destructor calls a function
- that calls the destructor again (loop)
+ Critical: The IOpenGLTexture2D destructor calls a function that calls
+ the destructor again (loop)
summary: - Critical: The IOpenGLTexture2D destructor calls a function that calls
- the destructor again (loop)
+ Critical issue: The IOpenGLTexture2D destructor calls a function that
+ calls the destructor again (loop)
description: updated
description: updated
Revision history for this message
Eleni Maria Stea (hikiko) wrote : Re: Critical issue: The IOpenGLTexture2D destructor calls a function that calls the destructor again (loop)

IOpenGLTexture2D texture destructor: 0x87d5618, function called: virtual nux::IOpenGLTexture2D::~IOpenGLTexture2D() FOR TEXTURE ID: 2701
IOpenGLResource destructor: 0x8886b18, function called: virtual nux::IOpenGLResource::~IOpenGLResource()
Object destructor: 0x8886b18, function called: virtual nux::Object::~Object()
I am not a texture, I can't be deleted ID: 2701
IOpenGLBaseTexture destructor: 0x87d5618, function called: virtual nux::IOpenGLBaseTexture::~IOpenGLBaseTexture()
IOpenGLResource destructor: 0x87d5618, function called: virtual nux::IOpenGLResource::~IOpenGLResource()
Object destructor: 0x87d5618, function called: virtual nux::Object::~Object()
IOpenGLTexture2D texture destructor: 0x87d5618, function called: virtual

nux::IOpenGLTexture2D::~IOpenGLTexture2D() FOR TEXTURE ID: 2702
IOpenGLResource destructor: 0x8886b18, function called: virtual nux::IOpenGLResource::~IOpenGLResource()
Object destructor: 0x8886b18, function called: virtual nux::Object::~Object()
I am not a texture, I can't be deleted ID: 2702
IOpenGLBaseTexture destructor: 0x87d5618, function called: virtual nux::IOpenGLBaseTexture::~IOpenGLBaseTexture()
IOpenGLResource destructor: 0x87d5618, function called: virtual nux::IOpenGLResource::~IOpenGLResource()
Object destructor: 0x87d5618, function called: virtual nux::Object::~Object()

[...]

I printed some more info to get sure that we have double calls because I realized that __PRETTY_FUNCTION__ returns the pointer to the parent constructor.

Revision history for this message
Eleni Maria Stea (hikiko) wrote :

2 different objects have the same texture id...

description: updated
Revision history for this message
Eleni Maria Stea (hikiko) wrote :

The loop was caused by something else which is fixed, still need to check if there are textures sharing the same id because we get texture related invalid operations on unity.

Changed in nux:
importance: Critical → Medium
status: New → In Progress
summary: - Critical issue: The IOpenGLTexture2D destructor calls a function that
- calls the destructor again (loop)
+ Invalid texture operations
Revision history for this message
Eleni Maria Stea (hikiko) wrote :

The texture hierarchy is fine, printed every single detail and checked. The loop was caused in specific examples by other errors that now have been fixed and merged.

Changed in nux:
status: In Progress → Fix Committed
Changed in nux:
assignee: Eleni Maria Stea (hikiko) → nobody
Stephen M. Webb (bregma)
Changed in nux:
status: Fix Committed → Fix Released
Changed in nux (Ubuntu):
status: New → Fix Released
importance: Undecided → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.