OpenGL python glTextImage2D crash by Bus error

359 views Asked by At

In my current python based OpenGL project I need to create a 2d texture by using glTexImage2d. Doing this I run into trouble when the texture width/height is greater than 888x888.

# crashes _sometimes_ when self._w * self._h > 888*888
glBindTexture(GL_TEXTURE_2D, self._id);
glTexImage2D(
    GL_TEXTURE_2D, 
    0, GL_RGB, 
    self._w, 
    self._h, 
    0, 
    GL_RGB, 
    GL_UNSIGNED_BYTE, 
    ''); # init an empty texture 

Some times its working, some times its not working resulting in a "Bus error: 10". Here are some details from the debug:

Crashed Thread:        0  Dispatch queue: com.apple.main-thread
Exception Type:        EXC_BAD_ACCESS (SIGBUS)
Exception Codes:       KERN_PROTECTION_FAILURE at 0x0000000103694000

hardware: mac book pro retina (2013):

Date/Time:             2015-06-22 21:30:53.795 +0200
OS Version:            Mac OS X 10.10.2 (14C109)
Report Version:        11

running the OpenGL core profile 4.1:

localhost:py keksnicoh$ python -m demos.plotter
[...] init GLFW
[...] load OPENGL_CORE_PROFILE 4.10
  + Vendor             Intel Inc.
  + Opengl version     4.1 INTEL-10.2.46
  + GLSL Version       4.10
  + Renderer           Intel Iris OpenGL Engine
  + GLFW3              3.0.4 Cocoa NSGL chdir menubar dynamic
GL_MAX_TEXTURE_SIZE 16384

During my research on this problem I found a very similar problem here on stack overflow EXC_BAD_ACCESS with glTexImage2D in GLKViewController . The solution was to setup a "lock" during invocation of glTexImage2d. The reason why this problem seem to fit my problem is that the invocation seems to crash randomly around 50% of the times which could indicate some kind of race-conditional problem.

Is there a way to implement a similar lock within my python Script or should I initialize the texture in another way? Note that the texture is empty on initialization since the texture will be written by a frame buffer.

UPDATE SOLVED Since I thought I tried it with None instead of empty string as init-value in glTexImage2d,I passed this empty string. The problem gets solved by this code

# crashes _sometimes_ when self._w * self._h > 888*888
glBindTexture(GL_TEXTURE_2D, self._id);
glTexImage2D(
    GL_TEXTURE_2D, 
    0, GL_RGB, 
    self._w, 
    self._h, 
    0, 
    GL_RGB, 
    GL_UNSIGNED_BYTE, 
    None); # <<<<---------------------- 

thanks derhass and datenwolf for the help!

0

There are 0 answers