OCIO crashes consistently on some devices in Krita 3.0
Closed, ResolvedPublic

Description

Steps:

  1. Turn on OCIO
  2. Observe crash.
woltherav updated the task description. (Show Details)
woltherav raised the priority of this task from to High.
woltherav added a project: Krita.
woltherav moved this task from Backlog to Krita 3.0 Regressions on the Krita board.
woltherav added a subscriber: woltherav.
woltherav added a comment.EditedDec 20 2015, 5:40 PM

The crash replaced itself with another.

  1. Turn on ocio(this gives me a black screen, btw)
  2. Close krita
  3. reopen Krita
  4. open image
  5. observe crash.
woltherav reopened this task as Open.Dec 20 2015, 8:18 PM

Yuck, happens deep down in OpenGLFunctions...

rempt added a subscriber: rempt.Dec 21 2015, 6:18 AM

Strange, because this doesn't happen for me now... At least not on the desktop. I'll try on my laptop instead.

woltherav renamed this task from OCIO crashes consistently in Krita 3.0 to OCIO crashes consistently on some devices in Krita 3.0.
sbrown added a subscriber: sbrown.Mar 27 2016, 5:17 AM

FWIW I get the black screen problem but not the crash on my machine. Spooky stuff.

Ok, I have black screen as well :)

woltherav reopened this task as Open.Apr 2 2016, 6:41 PM

Still have an ocio crash of sorts, but why...?

offending line at /home/krita/kde/src/krita/plugins/dockers/lut/ocio_display_filter.cpp:255
255 glFuncs3->glGenTextures(1, &m_lut3dTexID);

woltherav added a subscriber: Nim.EditedApr 2 2016, 7:06 PM

There's three possible paths to a crash for me:

  1. OpenGL+canvas and then turn on OCIO (edit: checked but this gives the same segfault as case 2)
  2. OpenGL+OCIO and make a canvas(previous backtrace)
  3. And OCIO+Canvas turn on OpenGL.

@Nim suggested I'd backtrace the 3rd as well, and indeed segfault happens on a different spot:

KisOpenGLImageTextures::createImageTextureTiles (this=0xb4e8750)
    at /home/krita/kde/src/krita/libs/ui/opengl/kis_opengl_image_textures.cpp:188
188	    const int pixelSize = m_tilesDestinationColorSpace->pixelSize();

Apparantly this laptop can't give OpenGL 3.2 functions according to qt, despite having access to 3.3 functions...

Changing

QOpenGLFunctions_3_2_Core *glFuncs3 = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_3_2_Core>();

to

QOpenGLFunctions_2_1 *glFuncs3 = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_2_1>();

And of course the relevant include fixes the problem for me, but no idea how to do this elegantly...

fazek added a subscriber: fazek.Apr 3 2016, 4:08 PM

I have a canvas and OpenGL on. Then I switch off OpenGL and exit the program. The program crashes with segfault in KisOpenGLImageTextures::destroyImageTextureTiles(). The crash happens when it calls delete tile, the deleted tile is the first on the list and it's value is not NULL.

Ok, thank you! I managed to reproduce it on another laptop

Works :) dunno about fazek's segfault though...

fazek added a comment.Apr 6 2016, 9:51 AM

My problem is still happens, perhaps not related but who knows? This is what I found:

After I disabled OpenGL, the KisTextureTiles on the m_textureTiles list remains in the memory until exiting the program, then the destructor of KisOpenGLImageTextures tries to delete them. This is when the crash happens.

When this happens, I think the QOpenGLFunctions table in the tile destructor (to call the glDeleteTextures) is already invalid. It also means the m_glFuncs in the KisOpenGLImageTextures is invalid as well.

But when this happens, actually there is a current, valid QOpenGLContext, but it has a different QOpenGLFunctions table (on a different memory address).

I tried to change both of these to use the table from the current QOpenGLContext (in the ~KisTextureTile() and ~KisOpenGLImageTextures() calls) and it seems working, at least there is no crash. But perhaps using a different table for creating and deleting is a dangerous idea. I think the program should purge all OpenGL related things right when the user disables OpenGL, while the original table is still valid.

But I'm afraid this is too much for me to solve.

It looks like the the tiles are leaking through the animation cache pointer stored in timeline docker

Hi, @fazek!

Please test now! The crash should be fixed! :)

fazek added a comment.Apr 6 2016, 4:17 PM

I think it's good now, no crash anymore.

woltherav closed this task as Resolved.Apr 6 2016, 11:26 PM
woltherav claimed this task.