Hi guys,
I’m writing an OpenGL ES app and from Xcode 9 beta 3 onwards I am getting this runtime error for every use of withUnsafePointer withMemoryRebound:
Simultaneous accesses to 0x7fe2d082ae80, but modification requires exclusive access.
Previous access (a modification) started at Leapfrog Viewer`SceneViewController.glkView(_:drawIn:) + 2034 (0x106627a72).
Current access (a read) started at:
0 libswiftCore.dylib 0x000000010b0d70e0 swift_beginAccess + 505
1 Leapfrog Viewer 0x000000010661f670 SceneViewController.normalMatrix.getter + 79
2 Leapfrog Viewer 0x0000000106628f40 closure #3 in SceneViewController.glkView(_:drawIn:) + 88
3 Leapfrog Viewer 0x00000001066290e0 partial apply for closure #3 in SceneViewController.glkView(_:drawIn:) + 58
... <edited>
19 UIKit 0x0000000108d3e8af UIApplicationMain + 159
20 Leapfrog Viewer 0x00000001066a0ad0 main + 55
21 libdyld.dylib 0x000000010ca6d3c4 start + 1
Xcode highlights this line:
withUnsafePointer(to: &normalMatrix) {
$0.withMemoryRebound(to: GLfloat.self, capacity: MemoryLayout.size(ofValue: normalMatrix)) {
glUniformMatrix3fv(uniforms[UNIFORM_NORMAL_MATRIX], 1, GLboolean(GL_FALSE), $0)
}
}
I know that Swift 4 is bringing in protections for simultaneous accesses of memory in a lot of situations, but I thought that Unsafe Pointers were being left to the dev to handle properly?
If this warning really is due to my own fault, how do I go about rewriting it to avoid the warning?
Thanks.