Using Xcode 7 beta, running the following OpenGL ES 2 code on Debug configuration on a iPhone 6 device running iOS 8.3, with Address Sanitizer enabled for the scheme, crashes:
#include <OpenGLES/ES2/glext.h>
//...
EAGLContext *contextA = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
if (!contextA || ![EAGLContext setCurrentContext:contextA]) {
return;
}
GLuint renderBuffer = 0;
glGenRenderbuffers(1, &renderBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer);
[contextA renderbufferStorage:GL_RENDERBUFFER fromDrawable:nil];
GLuint frameBuffer = 0;
glGenFramebuffers(1, &frameBuffer);
glBindFramebuffer(GL_FRAMEBUFFER, frameBuffer);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderBuffer);
glFlush();
EAGLContext *contextB = [[EAGLContext alloc] initWithAPI:contextA.API sharegroup:contextA.sharegroup];
if (!contextB || ![EAGLContext setCurrentContext:contextB]) {
return;
}
[contextB presentRenderbuffer:GL_RENDERBUFFER]; // EXC_BAD_ACCESS inside this function
Without Address Sanitizer, it run fine without crashing. It also does not crash if just rendering only on the first context and not the second. Everything in the code seems to follow the recommended procedure for using two contexts sharing the same share group. Is this a problem with Address Sanitizer? with the OpenGL library? with my code? or what?